<!DOCTYPE html>
<html lang="en-US">
<head>
    <meta charset="UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="language" content="en" />
        <link href="./assets/ffd55088/css/bootstrap.css" rel="stylesheet">
<link href="./assets/5cf9384a/solarized_light.css" rel="stylesheet">
<link href="./assets/6c54116e/style.css" rel="stylesheet">
<script src="./assets/a44cef0f/jquery.js"></script>
<script src="./assets/ffd55088/js/bootstrap.js"></script>
<script src="./assets/8ac4e28a/jssearch.js"></script>    <title>Query, yii\db\Query - Yii Framework 2.0 API Documentation</title>
</head>
<body>

<div class="wrap">
    <nav id="w9109" class="navbar-inverse navbar-fixed-top navbar" role="navigation"><div class="navbar-header"><button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#w9109-collapse"><span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span></button><a class="navbar-brand" href="./index.html">Yii Framework 2.0 API Documentation</a></div><div id="w9109-collapse" class="collapse navbar-collapse"><ul id="w9110" class="navbar-nav nav"><li><a href="./index.html">Class reference</a></li>
<li class="dropdown"><a class="dropdown-toggle" href="#" data-toggle="dropdown">Extensions <b class="caret"></b></a><ul id="w9111" class="dropdown-menu"><li><a href="./ext-apidoc-index.html" tabindex="-1">apidoc</a></li>
<li><a href="./ext-authclient-index.html" tabindex="-1">authclient</a></li>
<li><a href="./ext-bootstrap-index.html" tabindex="-1">bootstrap</a></li>
<li><a href="./ext-codeception-index.html" tabindex="-1">codeception</a></li>
<li><a href="./ext-debug-index.html" tabindex="-1">debug</a></li>
<li><a href="./ext-elasticsearch-index.html" tabindex="-1">elasticsearch</a></li>
<li><a href="./ext-faker-index.html" tabindex="-1">faker</a></li>
<li><a href="./ext-gii-index.html" tabindex="-1">gii</a></li>
<li><a href="./ext-imagine-index.html" tabindex="-1">imagine</a></li>
<li><a href="./ext-jui-index.html" tabindex="-1">jui</a></li>
<li><a href="./ext-mongodb-index.html" tabindex="-1">mongodb</a></li>
<li><a href="./ext-redis-index.html" tabindex="-1">redis</a></li>
<li><a href="./ext-smarty-index.html" tabindex="-1">smarty</a></li>
<li><a href="./ext-sphinx-index.html" tabindex="-1">sphinx</a></li>
<li><a href="./ext-swiftmailer-index.html" tabindex="-1">swiftmailer</a></li>
<li><a href="./ext-twig-index.html" tabindex="-1">twig</a></li></ul></li>
<li><a href="./guide-README.html">Guide</a></li></ul><div class="navbar-form navbar-left" role="search">
  <div class="form-group">
    <input id="searchbox" type="text" class="form-control" placeholder="Search">
  </div>
</div>
</div></nav>
    <div id="search-resultbox" style="display: none;" class="modal-content">
        <ul id="search-results">
        </ul>
    </div>

    
<div class="row">
    <div class="col-md-3">
                <div id="navigation" class="list-group"><a class="list-group-item" href="#navigation-9078" data-toggle="collapse" data-parent="#navigation">Not namespaced classes <b class="caret"></b></a><div id="navigation-9078" class="submenu panel-collapse collapse"><a class="list-group-item" href="./yii.html">Yii</a></div>
<a class="list-group-item" href="#navigation-9079" data-toggle="collapse" data-parent="#navigation">yii <b class="caret"></b></a><div id="navigation-9079" class="submenu panel-collapse collapse"><a class="list-group-item" href="./yii-baseyii.html">BaseYii</a></div>
<a class="list-group-item" href="#navigation-9080" data-toggle="collapse" data-parent="#navigation">yii\base <b class="caret"></b></a><div id="navigation-9080" class="submenu panel-collapse collapse"><a class="list-group-item" href="./yii-base-action.html">Action</a>
<a class="list-group-item" href="./yii-base-actionevent.html">ActionEvent</a>
<a class="list-group-item" href="./yii-base-actionfilter.html">ActionFilter</a>
<a class="list-group-item" href="./yii-base-application.html">Application</a>
<a class="list-group-item" href="./yii-base-arrayaccesstrait.html">ArrayAccessTrait</a>
<a class="list-group-item" href="./yii-base-arrayable.html">Arrayable</a>
<a class="list-group-item" href="./yii-base-arrayabletrait.html">ArrayableTrait</a>
<a class="list-group-item" href="./yii-base-behavior.html">Behavior</a>
<a class="list-group-item" href="./yii-base-bootstrapinterface.html">BootstrapInterface</a>
<a class="list-group-item" href="./yii-base-component.html">Component</a>
<a class="list-group-item" href="./yii-base-configurable.html">Configurable</a>
<a class="list-group-item" href="./yii-base-controller.html">Controller</a>
<a class="list-group-item" href="./yii-base-dynamicmodel.html">DynamicModel</a>
<a class="list-group-item" href="./yii-base-errorexception.html">ErrorException</a>
<a class="list-group-item" href="./yii-base-errorhandler.html">ErrorHandler</a>
<a class="list-group-item" href="./yii-base-event.html">Event</a>
<a class="list-group-item" href="./yii-base-exception.html">Exception</a>
<a class="list-group-item" href="./yii-base-exitexception.html">ExitException</a>
<a class="list-group-item" href="./yii-base-inlineaction.html">InlineAction</a>
<a class="list-group-item" href="./yii-base-invalidcallexception.html">InvalidCallException</a>
<a class="list-group-item" href="./yii-base-invalidconfigexception.html">InvalidConfigException</a>
<a class="list-group-item" href="./yii-base-invalidparamexception.html">InvalidParamException</a>
<a class="list-group-item" href="./yii-base-invalidrouteexception.html">InvalidRouteException</a>
<a class="list-group-item" href="./yii-base-invalidvalueexception.html">InvalidValueException</a>
<a class="list-group-item" href="./yii-base-model.html">Model</a>
<a class="list-group-item" href="./yii-base-modelevent.html">ModelEvent</a>
<a class="list-group-item" href="./yii-base-module.html">Module</a>
<a class="list-group-item" href="./yii-base-notsupportedexception.html">NotSupportedException</a>
<a class="list-group-item" href="./yii-base-object.html">Object</a>
<a class="list-group-item" href="./yii-base-request.html">Request</a>
<a class="list-group-item" href="./yii-base-response.html">Response</a>
<a class="list-group-item" href="./yii-base-security.html">Security</a>
<a class="list-group-item" href="./yii-base-theme.html">Theme</a>
<a class="list-group-item" href="./yii-base-unknownclassexception.html">UnknownClassException</a>
<a class="list-group-item" href="./yii-base-unknownmethodexception.html">UnknownMethodException</a>
<a class="list-group-item" href="./yii-base-unknownpropertyexception.html">UnknownPropertyException</a>
<a class="list-group-item" href="./yii-base-userexception.html">UserException</a>
<a class="list-group-item" href="./yii-base-view.html">View</a>
<a class="list-group-item" href="./yii-base-viewcontextinterface.html">ViewContextInterface</a>
<a class="list-group-item" href="./yii-base-viewevent.html">ViewEvent</a>
<a class="list-group-item" href="./yii-base-viewrenderer.html">ViewRenderer</a>
<a class="list-group-item" href="./yii-base-widget.html">Widget</a></div>
<a class="list-group-item" href="#navigation-9081" data-toggle="collapse" data-parent="#navigation">yii\behaviors <b class="caret"></b></a><div id="navigation-9081" class="submenu panel-collapse collapse"><a class="list-group-item" href="./yii-behaviors-attributebehavior.html">AttributeBehavior</a>
<a class="list-group-item" href="./yii-behaviors-blameablebehavior.html">BlameableBehavior</a>
<a class="list-group-item" href="./yii-behaviors-sluggablebehavior.html">SluggableBehavior</a>
<a class="list-group-item" href="./yii-behaviors-timestampbehavior.html">TimestampBehavior</a></div>
<a class="list-group-item" href="#navigation-9082" data-toggle="collapse" data-parent="#navigation">yii\caching <b class="caret"></b></a><div id="navigation-9082" class="submenu panel-collapse collapse"><a class="list-group-item" href="./yii-caching-apccache.html">ApcCache</a>
<a class="list-group-item" href="./yii-caching-arraycache.html">ArrayCache</a>
<a class="list-group-item" href="./yii-caching-cache.html">Cache</a>
<a class="list-group-item" href="./yii-caching-chaineddependency.html">ChainedDependency</a>
<a class="list-group-item" href="./yii-caching-dbcache.html">DbCache</a>
<a class="list-group-item" href="./yii-caching-dbdependency.html">DbDependency</a>
<a class="list-group-item" href="./yii-caching-dependency.html">Dependency</a>
<a class="list-group-item" href="./yii-caching-dummycache.html">DummyCache</a>
<a class="list-group-item" href="./yii-caching-expressiondependency.html">ExpressionDependency</a>
<a class="list-group-item" href="./yii-caching-filecache.html">FileCache</a>
<a class="list-group-item" href="./yii-caching-filedependency.html">FileDependency</a>
<a class="list-group-item" href="./yii-caching-memcache.html">MemCache</a>
<a class="list-group-item" href="./yii-caching-memcacheserver.html">MemCacheServer</a>
<a class="list-group-item" href="./yii-caching-tagdependency.html">TagDependency</a>
<a class="list-group-item" href="./yii-caching-wincache.html">WinCache</a>
<a class="list-group-item" href="./yii-caching-xcache.html">XCache</a>
<a class="list-group-item" href="./yii-caching-zenddatacache.html">ZendDataCache</a></div>
<a class="list-group-item" href="#navigation-9083" data-toggle="collapse" data-parent="#navigation">yii\captcha <b class="caret"></b></a><div id="navigation-9083" class="submenu panel-collapse collapse"><a class="list-group-item" href="./yii-captcha-captcha.html">Captcha</a>
<a class="list-group-item" href="./yii-captcha-captchaaction.html">CaptchaAction</a>
<a class="list-group-item" href="./yii-captcha-captchaasset.html">CaptchaAsset</a>
<a class="list-group-item" href="./yii-captcha-captchavalidator.html">CaptchaValidator</a></div>
<a class="list-group-item" href="#navigation-9084" data-toggle="collapse" data-parent="#navigation">yii\console <b class="caret"></b></a><div id="navigation-9084" class="submenu panel-collapse collapse"><a class="list-group-item" href="./yii-console-application.html">Application</a>
<a class="list-group-item" href="./yii-console-controller.html">Controller</a>
<a class="list-group-item" href="./yii-console-errorhandler.html">ErrorHandler</a>
<a class="list-group-item" href="./yii-console-exception.html">Exception</a>
<a class="list-group-item" href="./yii-console-markdown.html">Markdown</a>
<a class="list-group-item" href="./yii-console-request.html">Request</a>
<a class="list-group-item" href="./yii-console-response.html">Response</a></div>
<a class="list-group-item" href="#navigation-9085" data-toggle="collapse" data-parent="#navigation">yii\console\controllers <b class="caret"></b></a><div id="navigation-9085" class="submenu panel-collapse collapse"><a class="list-group-item" href="./yii-console-controllers-assetcontroller.html">AssetController</a>
<a class="list-group-item" href="./yii-console-controllers-basemigratecontroller.html">BaseMigrateController</a>
<a class="list-group-item" href="./yii-console-controllers-cachecontroller.html">CacheController</a>
<a class="list-group-item" href="./yii-console-controllers-fixturecontroller.html">FixtureController</a>
<a class="list-group-item" href="./yii-console-controllers-helpcontroller.html">HelpController</a>
<a class="list-group-item" href="./yii-console-controllers-messagecontroller.html">MessageController</a>
<a class="list-group-item" href="./yii-console-controllers-migratecontroller.html">MigrateController</a>
<a class="list-group-item" href="./yii-console-controllers-servecontroller.html">ServeController</a></div>
<a class="list-group-item" href="#navigation-9086" data-toggle="collapse" data-parent="#navigation">yii\data <b class="caret"></b></a><div id="navigation-9086" class="submenu panel-collapse collapse"><a class="list-group-item" href="./yii-data-activedataprovider.html">ActiveDataProvider</a>
<a class="list-group-item" href="./yii-data-arraydataprovider.html">ArrayDataProvider</a>
<a class="list-group-item" href="./yii-data-basedataprovider.html">BaseDataProvider</a>
<a class="list-group-item" href="./yii-data-dataproviderinterface.html">DataProviderInterface</a>
<a class="list-group-item" href="./yii-data-pagination.html">Pagination</a>
<a class="list-group-item" href="./yii-data-sort.html">Sort</a>
<a class="list-group-item" href="./yii-data-sqldataprovider.html">SqlDataProvider</a></div>
<a class="list-group-item active" href="#navigation-9087" data-toggle="collapse" data-parent="#navigation">yii\db <b class="caret"></b></a><div id="navigation-9087" class="submenu panel-collapse collapse in"><a class="list-group-item" href="./yii-db-activequery.html">ActiveQuery</a>
<a class="list-group-item" href="./yii-db-activequeryinterface.html">ActiveQueryInterface</a>
<a class="list-group-item" href="./yii-db-activequerytrait.html">ActiveQueryTrait</a>
<a class="list-group-item" href="./yii-db-activerecord.html">ActiveRecord</a>
<a class="list-group-item" href="./yii-db-activerecordinterface.html">ActiveRecordInterface</a>
<a class="list-group-item" href="./yii-db-activerelationtrait.html">ActiveRelationTrait</a>
<a class="list-group-item" href="./yii-db-aftersaveevent.html">AfterSaveEvent</a>
<a class="list-group-item" href="./yii-db-baseactiverecord.html">BaseActiveRecord</a>
<a class="list-group-item" href="./yii-db-batchqueryresult.html">BatchQueryResult</a>
<a class="list-group-item" href="./yii-db-columnschema.html">ColumnSchema</a>
<a class="list-group-item" href="./yii-db-columnschemabuilder.html">ColumnSchemaBuilder</a>
<a class="list-group-item" href="./yii-db-command.html">Command</a>
<a class="list-group-item" href="./yii-db-connection.html">Connection</a>
<a class="list-group-item" href="./yii-db-datareader.html">DataReader</a>
<a class="list-group-item" href="./yii-db-exception.html">Exception</a>
<a class="list-group-item" href="./yii-db-expression.html">Expression</a>
<a class="list-group-item" href="./yii-db-integrityexception.html">IntegrityException</a>
<a class="list-group-item" href="./yii-db-migration.html">Migration</a>
<a class="list-group-item" href="./yii-db-migrationinterface.html">MigrationInterface</a>
<a class="list-group-item active" href="./yii-db-query.html">Query</a>
<a class="list-group-item" href="./yii-db-querybuilder.html">QueryBuilder</a>
<a class="list-group-item" href="./yii-db-queryinterface.html">QueryInterface</a>
<a class="list-group-item" href="./yii-db-querytrait.html">QueryTrait</a>
<a class="list-group-item" href="./yii-db-schema.html">Schema</a>
<a class="list-group-item" href="./yii-db-schemabuildertrait.html">SchemaBuilderTrait</a>
<a class="list-group-item" href="./yii-db-staleobjectexception.html">StaleObjectException</a>
<a class="list-group-item" href="./yii-db-tableschema.html">TableSchema</a>
<a class="list-group-item" href="./yii-db-transaction.html">Transaction</a></div>
<a class="list-group-item" href="#navigation-9088" data-toggle="collapse" data-parent="#navigation">yii\db\cubrid <b class="caret"></b></a><div id="navigation-9088" class="submenu panel-collapse collapse"><a class="list-group-item" href="./yii-db-cubrid-columnschemabuilder.html">ColumnSchemaBuilder</a>
<a class="list-group-item" href="./yii-db-cubrid-querybuilder.html">QueryBuilder</a>
<a class="list-group-item" href="./yii-db-cubrid-schema.html">Schema</a></div>
<a class="list-group-item" href="#navigation-9089" data-toggle="collapse" data-parent="#navigation">yii\db\mssql <b class="caret"></b></a><div id="navigation-9089" class="submenu panel-collapse collapse"><a class="list-group-item" href="./yii-db-mssql-pdo.html">PDO</a>
<a class="list-group-item" href="./yii-db-mssql-querybuilder.html">QueryBuilder</a>
<a class="list-group-item" href="./yii-db-mssql-schema.html">Schema</a>
<a class="list-group-item" href="./yii-db-mssql-sqlsrvpdo.html">SqlsrvPDO</a>
<a class="list-group-item" href="./yii-db-mssql-tableschema.html">TableSchema</a></div>
<a class="list-group-item" href="#navigation-9090" data-toggle="collapse" data-parent="#navigation">yii\db\mysql <b class="caret"></b></a><div id="navigation-9090" class="submenu panel-collapse collapse"><a class="list-group-item" href="./yii-db-mysql-columnschemabuilder.html">ColumnSchemaBuilder</a>
<a class="list-group-item" href="./yii-db-mysql-querybuilder.html">QueryBuilder</a>
<a class="list-group-item" href="./yii-db-mysql-schema.html">Schema</a></div>
<a class="list-group-item" href="#navigation-9091" data-toggle="collapse" data-parent="#navigation">yii\db\oci <b class="caret"></b></a><div id="navigation-9091" class="submenu panel-collapse collapse"><a class="list-group-item" href="./yii-db-oci-columnschemabuilder.html">ColumnSchemaBuilder</a>
<a class="list-group-item" href="./yii-db-oci-querybuilder.html">QueryBuilder</a>
<a class="list-group-item" href="./yii-db-oci-schema.html">Schema</a></div>
<a class="list-group-item" href="#navigation-9092" data-toggle="collapse" data-parent="#navigation">yii\db\pgsql <b class="caret"></b></a><div id="navigation-9092" class="submenu panel-collapse collapse"><a class="list-group-item" href="./yii-db-pgsql-querybuilder.html">QueryBuilder</a>
<a class="list-group-item" href="./yii-db-pgsql-schema.html">Schema</a></div>
<a class="list-group-item" href="#navigation-9093" data-toggle="collapse" data-parent="#navigation">yii\db\sqlite <b class="caret"></b></a><div id="navigation-9093" class="submenu panel-collapse collapse"><a class="list-group-item" href="./yii-db-sqlite-columnschemabuilder.html">ColumnSchemaBuilder</a>
<a class="list-group-item" href="./yii-db-sqlite-querybuilder.html">QueryBuilder</a>
<a class="list-group-item" href="./yii-db-sqlite-schema.html">Schema</a></div>
<a class="list-group-item" href="#navigation-9094" data-toggle="collapse" data-parent="#navigation">yii\di <b class="caret"></b></a><div id="navigation-9094" class="submenu panel-collapse collapse"><a class="list-group-item" href="./yii-di-container.html">Container</a>
<a class="list-group-item" href="./yii-di-instance.html">Instance</a>
<a class="list-group-item" href="./yii-di-notinstantiableexception.html">NotInstantiableException</a>
<a class="list-group-item" href="./yii-di-servicelocator.html">ServiceLocator</a></div>
<a class="list-group-item" href="#navigation-9095" data-toggle="collapse" data-parent="#navigation">yii\filters <b class="caret"></b></a><div id="navigation-9095" class="submenu panel-collapse collapse"><a class="list-group-item" href="./yii-filters-accesscontrol.html">AccessControl</a>
<a class="list-group-item" href="./yii-filters-accessrule.html">AccessRule</a>
<a class="list-group-item" href="./yii-filters-contentnegotiator.html">ContentNegotiator</a>
<a class="list-group-item" href="./yii-filters-cors.html">Cors</a>
<a class="list-group-item" href="./yii-filters-httpcache.html">HttpCache</a>
<a class="list-group-item" href="./yii-filters-pagecache.html">PageCache</a>
<a class="list-group-item" href="./yii-filters-ratelimitinterface.html">RateLimitInterface</a>
<a class="list-group-item" href="./yii-filters-ratelimiter.html">RateLimiter</a>
<a class="list-group-item" href="./yii-filters-verbfilter.html">VerbFilter</a></div>
<a class="list-group-item" href="#navigation-9096" data-toggle="collapse" data-parent="#navigation">yii\filters\auth <b class="caret"></b></a><div id="navigation-9096" class="submenu panel-collapse collapse"><a class="list-group-item" href="./yii-filters-auth-authinterface.html">AuthInterface</a>
<a class="list-group-item" href="./yii-filters-auth-authmethod.html">AuthMethod</a>
<a class="list-group-item" href="./yii-filters-auth-compositeauth.html">CompositeAuth</a>
<a class="list-group-item" href="./yii-filters-auth-httpbasicauth.html">HttpBasicAuth</a>
<a class="list-group-item" href="./yii-filters-auth-httpbearerauth.html">HttpBearerAuth</a>
<a class="list-group-item" href="./yii-filters-auth-queryparamauth.html">QueryParamAuth</a></div>
<a class="list-group-item" href="#navigation-9097" data-toggle="collapse" data-parent="#navigation">yii\grid <b class="caret"></b></a><div id="navigation-9097" class="submenu panel-collapse collapse"><a class="list-group-item" href="./yii-grid-actioncolumn.html">ActionColumn</a>
<a class="list-group-item" href="./yii-grid-checkboxcolumn.html">CheckboxColumn</a>
<a class="list-group-item" href="./yii-grid-column.html">Column</a>
<a class="list-group-item" href="./yii-grid-datacolumn.html">DataColumn</a>
<a class="list-group-item" href="./yii-grid-gridview.html">GridView</a>
<a class="list-group-item" href="./yii-grid-gridviewasset.html">GridViewAsset</a>
<a class="list-group-item" href="./yii-grid-serialcolumn.html">SerialColumn</a></div>
<a class="list-group-item" href="#navigation-9098" data-toggle="collapse" data-parent="#navigation">yii\helpers <b class="caret"></b></a><div id="navigation-9098" class="submenu panel-collapse collapse"><a class="list-group-item" href="./yii-helpers-arrayhelper.html">ArrayHelper</a>
<a class="list-group-item" href="./yii-helpers-basearrayhelper.html">BaseArrayHelper</a>
<a class="list-group-item" href="./yii-helpers-baseconsole.html">BaseConsole</a>
<a class="list-group-item" href="./yii-helpers-basefilehelper.html">BaseFileHelper</a>
<a class="list-group-item" href="./yii-helpers-baseformatconverter.html">BaseFormatConverter</a>
<a class="list-group-item" href="./yii-helpers-basehtml.html">BaseHtml</a>
<a class="list-group-item" href="./yii-helpers-basehtmlpurifier.html">BaseHtmlPurifier</a>
<a class="list-group-item" href="./yii-helpers-baseinflector.html">BaseInflector</a>
<a class="list-group-item" href="./yii-helpers-basejson.html">BaseJson</a>
<a class="list-group-item" href="./yii-helpers-basemarkdown.html">BaseMarkdown</a>
<a class="list-group-item" href="./yii-helpers-basestringhelper.html">BaseStringHelper</a>
<a class="list-group-item" href="./yii-helpers-baseurl.html">BaseUrl</a>
<a class="list-group-item" href="./yii-helpers-basevardumper.html">BaseVarDumper</a>
<a class="list-group-item" href="./yii-helpers-console.html">Console</a>
<a class="list-group-item" href="./yii-helpers-filehelper.html">FileHelper</a>
<a class="list-group-item" href="./yii-helpers-formatconverter.html">FormatConverter</a>
<a class="list-group-item" href="./yii-helpers-html.html">Html</a>
<a class="list-group-item" href="./yii-helpers-htmlpurifier.html">HtmlPurifier</a>
<a class="list-group-item" href="./yii-helpers-inflector.html">Inflector</a>
<a class="list-group-item" href="./yii-helpers-json.html">Json</a>
<a class="list-group-item" href="./yii-helpers-markdown.html">Markdown</a>
<a class="list-group-item" href="./yii-helpers-stringhelper.html">StringHelper</a>
<a class="list-group-item" href="./yii-helpers-url.html">Url</a>
<a class="list-group-item" href="./yii-helpers-vardumper.html">VarDumper</a></div>
<a class="list-group-item" href="#navigation-9099" data-toggle="collapse" data-parent="#navigation">yii\i18n <b class="caret"></b></a><div id="navigation-9099" class="submenu panel-collapse collapse"><a class="list-group-item" href="./yii-i18n-dbmessagesource.html">DbMessageSource</a>
<a class="list-group-item" href="./yii-i18n-formatter.html">Formatter</a>
<a class="list-group-item" href="./yii-i18n-gettextfile.html">GettextFile</a>
<a class="list-group-item" href="./yii-i18n-gettextmessagesource.html">GettextMessageSource</a>
<a class="list-group-item" href="./yii-i18n-gettextmofile.html">GettextMoFile</a>
<a class="list-group-item" href="./yii-i18n-gettextpofile.html">GettextPoFile</a>
<a class="list-group-item" href="./yii-i18n-i18n.html">I18N</a>
<a class="list-group-item" href="./yii-i18n-messageformatter.html">MessageFormatter</a>
<a class="list-group-item" href="./yii-i18n-messagesource.html">MessageSource</a>
<a class="list-group-item" href="./yii-i18n-missingtranslationevent.html">MissingTranslationEvent</a>
<a class="list-group-item" href="./yii-i18n-phpmessagesource.html">PhpMessageSource</a></div>
<a class="list-group-item" href="#navigation-9100" data-toggle="collapse" data-parent="#navigation">yii\log <b class="caret"></b></a><div id="navigation-9100" class="submenu panel-collapse collapse"><a class="list-group-item" href="./yii-log-dbtarget.html">DbTarget</a>
<a class="list-group-item" href="./yii-log-dispatcher.html">Dispatcher</a>
<a class="list-group-item" href="./yii-log-emailtarget.html">EmailTarget</a>
<a class="list-group-item" href="./yii-log-filetarget.html">FileTarget</a>
<a class="list-group-item" href="./yii-log-logger.html">Logger</a>
<a class="list-group-item" href="./yii-log-syslogtarget.html">SyslogTarget</a>
<a class="list-group-item" href="./yii-log-target.html">Target</a></div>
<a class="list-group-item" href="#navigation-9101" data-toggle="collapse" data-parent="#navigation">yii\mail <b class="caret"></b></a><div id="navigation-9101" class="submenu panel-collapse collapse"><a class="list-group-item" href="./yii-mail-basemailer.html">BaseMailer</a>
<a class="list-group-item" href="./yii-mail-basemessage.html">BaseMessage</a>
<a class="list-group-item" href="./yii-mail-mailevent.html">MailEvent</a>
<a class="list-group-item" href="./yii-mail-mailerinterface.html">MailerInterface</a>
<a class="list-group-item" href="./yii-mail-messageinterface.html">MessageInterface</a></div>
<a class="list-group-item" href="#navigation-9102" data-toggle="collapse" data-parent="#navigation">yii\mutex <b class="caret"></b></a><div id="navigation-9102" class="submenu panel-collapse collapse"><a class="list-group-item" href="./yii-mutex-dbmutex.html">DbMutex</a>
<a class="list-group-item" href="./yii-mutex-filemutex.html">FileMutex</a>
<a class="list-group-item" href="./yii-mutex-mutex.html">Mutex</a>
<a class="list-group-item" href="./yii-mutex-mysqlmutex.html">MysqlMutex</a>
<a class="list-group-item" href="./yii-mutex-pgsqlmutex.html">PgsqlMutex</a></div>
<a class="list-group-item" href="#navigation-9103" data-toggle="collapse" data-parent="#navigation">yii\rbac <b class="caret"></b></a><div id="navigation-9103" class="submenu panel-collapse collapse"><a class="list-group-item" href="./yii-rbac-assignment.html">Assignment</a>
<a class="list-group-item" href="./yii-rbac-basemanager.html">BaseManager</a>
<a class="list-group-item" href="./yii-rbac-checkaccessinterface.html">CheckAccessInterface</a>
<a class="list-group-item" href="./yii-rbac-dbmanager.html">DbManager</a>
<a class="list-group-item" href="./yii-rbac-item.html">Item</a>
<a class="list-group-item" href="./yii-rbac-managerinterface.html">ManagerInterface</a>
<a class="list-group-item" href="./yii-rbac-permission.html">Permission</a>
<a class="list-group-item" href="./yii-rbac-phpmanager.html">PhpManager</a>
<a class="list-group-item" href="./yii-rbac-role.html">Role</a>
<a class="list-group-item" href="./yii-rbac-rule.html">Rule</a></div>
<a class="list-group-item" href="#navigation-9104" data-toggle="collapse" data-parent="#navigation">yii\rest <b class="caret"></b></a><div id="navigation-9104" class="submenu panel-collapse collapse"><a class="list-group-item" href="./yii-rest-action.html">Action</a>
<a class="list-group-item" href="./yii-rest-activecontroller.html">ActiveController</a>
<a class="list-group-item" href="./yii-rest-controller.html">Controller</a>
<a class="list-group-item" href="./yii-rest-createaction.html">CreateAction</a>
<a class="list-group-item" href="./yii-rest-deleteaction.html">DeleteAction</a>
<a class="list-group-item" href="./yii-rest-indexaction.html">IndexAction</a>
<a class="list-group-item" href="./yii-rest-optionsaction.html">OptionsAction</a>
<a class="list-group-item" href="./yii-rest-serializer.html">Serializer</a>
<a class="list-group-item" href="./yii-rest-updateaction.html">UpdateAction</a>
<a class="list-group-item" href="./yii-rest-urlrule.html">UrlRule</a>
<a class="list-group-item" href="./yii-rest-viewaction.html">ViewAction</a></div>
<a class="list-group-item" href="#navigation-9105" data-toggle="collapse" data-parent="#navigation">yii\test <b class="caret"></b></a><div id="navigation-9105" class="submenu panel-collapse collapse"><a class="list-group-item" href="./yii-test-activefixture.html">ActiveFixture</a>
<a class="list-group-item" href="./yii-test-arrayfixture.html">ArrayFixture</a>
<a class="list-group-item" href="./yii-test-baseactivefixture.html">BaseActiveFixture</a>
<a class="list-group-item" href="./yii-test-dbfixture.html">DbFixture</a>
<a class="list-group-item" href="./yii-test-fixture.html">Fixture</a>
<a class="list-group-item" href="./yii-test-fixturetrait.html">FixtureTrait</a>
<a class="list-group-item" href="./yii-test-initdbfixture.html">InitDbFixture</a></div>
<a class="list-group-item" href="#navigation-9106" data-toggle="collapse" data-parent="#navigation">yii\validators <b class="caret"></b></a><div id="navigation-9106" class="submenu panel-collapse collapse"><a class="list-group-item" href="./yii-validators-booleanvalidator.html">BooleanValidator</a>
<a class="list-group-item" href="./yii-validators-comparevalidator.html">CompareValidator</a>
<a class="list-group-item" href="./yii-validators-datevalidator.html">DateValidator</a>
<a class="list-group-item" href="./yii-validators-defaultvaluevalidator.html">DefaultValueValidator</a>
<a class="list-group-item" href="./yii-validators-eachvalidator.html">EachValidator</a>
<a class="list-group-item" href="./yii-validators-emailvalidator.html">EmailValidator</a>
<a class="list-group-item" href="./yii-validators-existvalidator.html">ExistValidator</a>
<a class="list-group-item" href="./yii-validators-filevalidator.html">FileValidator</a>
<a class="list-group-item" href="./yii-validators-filtervalidator.html">FilterValidator</a>
<a class="list-group-item" href="./yii-validators-imagevalidator.html">ImageValidator</a>
<a class="list-group-item" href="./yii-validators-inlinevalidator.html">InlineValidator</a>
<a class="list-group-item" href="./yii-validators-ipvalidator.html">IpValidator</a>
<a class="list-group-item" href="./yii-validators-numbervalidator.html">NumberValidator</a>
<a class="list-group-item" href="./yii-validators-punycodeasset.html">PunycodeAsset</a>
<a class="list-group-item" href="./yii-validators-rangevalidator.html">RangeValidator</a>
<a class="list-group-item" href="./yii-validators-regularexpressionvalidator.html">RegularExpressionValidator</a>
<a class="list-group-item" href="./yii-validators-requiredvalidator.html">RequiredValidator</a>
<a class="list-group-item" href="./yii-validators-safevalidator.html">SafeValidator</a>
<a class="list-group-item" href="./yii-validators-stringvalidator.html">StringValidator</a>
<a class="list-group-item" href="./yii-validators-uniquevalidator.html">UniqueValidator</a>
<a class="list-group-item" href="./yii-validators-urlvalidator.html">UrlValidator</a>
<a class="list-group-item" href="./yii-validators-validationasset.html">ValidationAsset</a>
<a class="list-group-item" href="./yii-validators-validator.html">Validator</a></div>
<a class="list-group-item" href="#navigation-9107" data-toggle="collapse" data-parent="#navigation">yii\web <b class="caret"></b></a><div id="navigation-9107" class="submenu panel-collapse collapse"><a class="list-group-item" href="./yii-web-application.html">Application</a>
<a class="list-group-item" href="./yii-web-assetbundle.html">AssetBundle</a>
<a class="list-group-item" href="./yii-web-assetconverter.html">AssetConverter</a>
<a class="list-group-item" href="./yii-web-assetconverterinterface.html">AssetConverterInterface</a>
<a class="list-group-item" href="./yii-web-assetmanager.html">AssetManager</a>
<a class="list-group-item" href="./yii-web-badrequesthttpexception.html">BadRequestHttpException</a>
<a class="list-group-item" href="./yii-web-cachesession.html">CacheSession</a>
<a class="list-group-item" href="./yii-web-compositeurlrule.html">CompositeUrlRule</a>
<a class="list-group-item" href="./yii-web-conflicthttpexception.html">ConflictHttpException</a>
<a class="list-group-item" href="./yii-web-controller.html">Controller</a>
<a class="list-group-item" href="./yii-web-cookie.html">Cookie</a>
<a class="list-group-item" href="./yii-web-cookiecollection.html">CookieCollection</a>
<a class="list-group-item" href="./yii-web-dbsession.html">DbSession</a>
<a class="list-group-item" href="./yii-web-erroraction.html">ErrorAction</a>
<a class="list-group-item" href="./yii-web-errorhandler.html">ErrorHandler</a>
<a class="list-group-item" href="./yii-web-forbiddenhttpexception.html">ForbiddenHttpException</a>
<a class="list-group-item" href="./yii-web-gonehttpexception.html">GoneHttpException</a>
<a class="list-group-item" href="./yii-web-groupurlrule.html">GroupUrlRule</a>
<a class="list-group-item" href="./yii-web-headercollection.html">HeaderCollection</a>
<a class="list-group-item" href="./yii-web-htmlresponseformatter.html">HtmlResponseFormatter</a>
<a class="list-group-item" href="./yii-web-httpexception.html">HttpException</a>
<a class="list-group-item" href="./yii-web-identityinterface.html">IdentityInterface</a>
<a class="list-group-item" href="./yii-web-jqueryasset.html">JqueryAsset</a>
<a class="list-group-item" href="./yii-web-jsexpression.html">JsExpression</a>
<a class="list-group-item" href="./yii-web-jsonparser.html">JsonParser</a>
<a class="list-group-item" href="./yii-web-jsonresponseformatter.html">JsonResponseFormatter</a>
<a class="list-group-item" href="./yii-web-link.html">Link</a>
<a class="list-group-item" href="./yii-web-linkable.html">Linkable</a>
<a class="list-group-item" href="./yii-web-methodnotallowedhttpexception.html">MethodNotAllowedHttpException</a>
<a class="list-group-item" href="./yii-web-multifieldsession.html">MultiFieldSession</a>
<a class="list-group-item" href="./yii-web-notacceptablehttpexception.html">NotAcceptableHttpException</a>
<a class="list-group-item" href="./yii-web-notfoundhttpexception.html">NotFoundHttpException</a>
<a class="list-group-item" href="./yii-web-request.html">Request</a>
<a class="list-group-item" href="./yii-web-requestparserinterface.html">RequestParserInterface</a>
<a class="list-group-item" href="./yii-web-response.html">Response</a>
<a class="list-group-item" href="./yii-web-responseformatterinterface.html">ResponseFormatterInterface</a>
<a class="list-group-item" href="./yii-web-servererrorhttpexception.html">ServerErrorHttpException</a>
<a class="list-group-item" href="./yii-web-session.html">Session</a>
<a class="list-group-item" href="./yii-web-sessioniterator.html">SessionIterator</a>
<a class="list-group-item" href="./yii-web-toomanyrequestshttpexception.html">TooManyRequestsHttpException</a>
<a class="list-group-item" href="./yii-web-unauthorizedhttpexception.html">UnauthorizedHttpException</a>
<a class="list-group-item" href="./yii-web-unprocessableentityhttpexception.html">UnprocessableEntityHttpException</a>
<a class="list-group-item" href="./yii-web-unsupportedmediatypehttpexception.html">UnsupportedMediaTypeHttpException</a>
<a class="list-group-item" href="./yii-web-uploadedfile.html">UploadedFile</a>
<a class="list-group-item" href="./yii-web-urlmanager.html">UrlManager</a>
<a class="list-group-item" href="./yii-web-urlrule.html">UrlRule</a>
<a class="list-group-item" href="./yii-web-urlruleinterface.html">UrlRuleInterface</a>
<a class="list-group-item" href="./yii-web-user.html">User</a>
<a class="list-group-item" href="./yii-web-userevent.html">UserEvent</a>
<a class="list-group-item" href="./yii-web-view.html">View</a>
<a class="list-group-item" href="./yii-web-viewaction.html">ViewAction</a>
<a class="list-group-item" href="./yii-web-xmlresponseformatter.html">XmlResponseFormatter</a>
<a class="list-group-item" href="./yii-web-yiiasset.html">YiiAsset</a></div>
<a class="list-group-item" href="#navigation-9108" data-toggle="collapse" data-parent="#navigation">yii\widgets <b class="caret"></b></a><div id="navigation-9108" class="submenu panel-collapse collapse"><a class="list-group-item" href="./yii-widgets-activefield.html">ActiveField</a>
<a class="list-group-item" href="./yii-widgets-activeform.html">ActiveForm</a>
<a class="list-group-item" href="./yii-widgets-activeformasset.html">ActiveFormAsset</a>
<a class="list-group-item" href="./yii-widgets-baselistview.html">BaseListView</a>
<a class="list-group-item" href="./yii-widgets-block.html">Block</a>
<a class="list-group-item" href="./yii-widgets-breadcrumbs.html">Breadcrumbs</a>
<a class="list-group-item" href="./yii-widgets-contentdecorator.html">ContentDecorator</a>
<a class="list-group-item" href="./yii-widgets-detailview.html">DetailView</a>
<a class="list-group-item" href="./yii-widgets-fragmentcache.html">FragmentCache</a>
<a class="list-group-item" href="./yii-widgets-inputwidget.html">InputWidget</a>
<a class="list-group-item" href="./yii-widgets-linkpager.html">LinkPager</a>
<a class="list-group-item" href="./yii-widgets-linksorter.html">LinkSorter</a>
<a class="list-group-item" href="./yii-widgets-listview.html">ListView</a>
<a class="list-group-item" href="./yii-widgets-maskedinput.html">MaskedInput</a>
<a class="list-group-item" href="./yii-widgets-maskedinputasset.html">MaskedInputAsset</a>
<a class="list-group-item" href="./yii-widgets-menu.html">Menu</a>
<a class="list-group-item" href="./yii-widgets-pjax.html">Pjax</a>
<a class="list-group-item" href="./yii-widgets-pjaxasset.html">PjaxAsset</a>
<a class="list-group-item" href="./yii-widgets-spaceless.html">Spaceless</a></div></div>    </div>
    <div class="col-md-9 api-content" role="main">
        <h1>Class yii\db\Query</h1>
<div class="top-nav">
    <a href="index.html">All Classes</a>
            | <a href="#properties">Properties</a>
                | <a href="#methods">Methods</a>
            </div>

<table class="summaryTable docClass table table-bordered">
    <colgroup>
        <col class="col-name" />
        <col class="col-value" />
    </colgroup>
            <tr><th>Inheritance</th><td><a href="yii-db-query.html">yii\db\Query</a> &raquo;
<a href="yii-base-component.html">yii\base\Component</a> &raquo;
<a href="yii-base-object.html">yii\base\Object</a></td></tr>
                <tr><th>Implements</th><td><a href="yii-base-configurable.html">yii\base\Configurable</a>, <a href="yii-db-queryinterface.html">yii\db\QueryInterface</a></td></tr>
                    <tr><th>Uses Traits</th><td><a href="yii-db-querytrait.html">yii\db\QueryTrait</a></td></tr>
                <tr><th>Subclasses</th><td><a href="yii-db-activequery.html">yii\db\ActiveQuery</a>, <a href="yii-sphinx-activequery.html">yii\sphinx\ActiveQuery</a>, <a href="yii-sphinx-query.html">yii\sphinx\Query</a></td></tr>
                        <tr><th>Available since version</th><td>2.0</td></tr>
                    <tr>
          <th>Source Code</th>
          <td><a href="https://github.com/yiisoft/yii2/blob/master/framework/db/Query.php">https://github.com/yiisoft/yii2/blob/master/framework/db/Query.php</a></td>
        </tr>
    </table>

<div class="class-description">
    <p><strong>Query represents a SELECT SQL statement in a way that is independent of DBMS.</strong></p>
    <p>Query provides a set of methods to facilitate the specification of different clauses
in a SELECT statement. These methods can be chained together.</p>
<p>By calling <a href="yii-db-query.html#createCommand()-detail">createCommand()</a>, we can get a <a href="yii-db-command.html">yii\db\Command</a> instance which can be further
used to perform/execute the DB query against a database.</p>
<p>For example,</p>
<pre><code class="hljs php language-php"><span class="hljs-variable">$query</span> = <span class="hljs-keyword">new</span> Query;
<span class="hljs-comment">// compose the query</span>
<span class="hljs-variable">$query</span>-&gt;select(<span class="hljs-string">'id, name'</span>)
    -&gt;from(<span class="hljs-string">'user'</span>)
    -&gt;limit(<span class="hljs-number">10</span>);
<span class="hljs-comment">// build and execute the query</span>
<span class="hljs-variable">$rows</span> = <span class="hljs-variable">$query</span>-&gt;all();
<span class="hljs-comment">// alternatively, you can create DB command and execute it</span>
<span class="hljs-variable">$command</span> = <span class="hljs-variable">$query</span>-&gt;createCommand();
<span class="hljs-comment">// $command-&gt;sql returns the actual SQL</span>
<span class="hljs-variable">$rows</span> = <span class="hljs-variable">$command</span>-&gt;queryAll();
</code></pre>
<p>Query internally uses the <a href="yii-db-querybuilder.html">yii\db\QueryBuilder</a> class to generate the SQL statement.</p>
<p>A more detailed usage guide on how to work with Query can be found in the <a href="./guide-db-query-builder.html">guide article on Query Builder</a>.</p>

    </div>

<a id="properties"></a>

<div class="summary doc-property">
<h2>Public Properties</h2>

<p><a href="#" class="toggle">Hide inherited properties</a></p>

<table class="summary-table table table-striped table-bordered table-hover">
<colgroup>
    <col class="col-property" />
    <col class="col-type" />
    <col class="col-description" />
    <col class="col-defined" />
</colgroup>
<tr>
  <th>Property</th><th>Type</th><th>Description</th><th>Defined By</th>
</tr>
        <tr class="inherited" id="$behaviors">
        <td><a href="yii-base-component.html#$behaviors-detail">$behaviors</a></td>
        <td><a href="yii-base-behavior.html">yii\base\Behavior</a>[]</td>
        <td>List of behaviors attached to this component</td>
        <td><a href="yii-base-component.html">yii\base\Component</a></td>
    </tr>
            <tr id="$distinct">
        <td><a href="yii-db-query.html#$distinct-detail">$distinct</a></td>
        <td><a href="http://www.php.net/language.types.boolean">boolean</a></td>
        <td>Whether to select distinct rows of data only.</td>
        <td><a href="yii-db-query.html">yii\db\Query</a></td>
    </tr>
            <tr id="$from">
        <td><a href="yii-db-query.html#$from-detail">$from</a></td>
        <td><a href="http://www.php.net/language.types.array">array</a></td>
        <td>The table(s) to be selected from.</td>
        <td><a href="yii-db-query.html">yii\db\Query</a></td>
    </tr>
            <tr id="$groupBy">
        <td><a href="yii-db-query.html#$groupBy-detail">$groupBy</a></td>
        <td><a href="http://www.php.net/language.types.array">array</a></td>
        <td>How to group the query results.</td>
        <td><a href="yii-db-query.html">yii\db\Query</a></td>
    </tr>
            <tr id="$having">
        <td><a href="yii-db-query.html#$having-detail">$having</a></td>
        <td><a href="http://www.php.net/language.types.string">string</a>|<a href="http://www.php.net/language.types.array">array</a></td>
        <td>The condition to be applied in the GROUP BY clause.</td>
        <td><a href="yii-db-query.html">yii\db\Query</a></td>
    </tr>
            <tr class="inherited" id="$indexBy">
        <td><a href="yii-db-querytrait.html#$indexBy-detail">$indexBy</a></td>
        <td><a href="http://www.php.net/language.types.string">string</a>|<a href="http://www.php.net/language.types.callable">callable</a></td>
        <td>The name of the column by which the query results should be indexed by.</td>
        <td><a href="yii-db-querytrait.html">yii\db\QueryTrait</a></td>
    </tr>
            <tr id="$join">
        <td><a href="yii-db-query.html#$join-detail">$join</a></td>
        <td><a href="http://www.php.net/language.types.array">array</a></td>
        <td>How to join with other tables.</td>
        <td><a href="yii-db-query.html">yii\db\Query</a></td>
    </tr>
            <tr class="inherited" id="$limit">
        <td><a href="yii-db-querytrait.html#$limit-detail">$limit</a></td>
        <td><a href="http://www.php.net/language.types.integer">integer</a></td>
        <td>Maximum number of records to be returned.</td>
        <td><a href="yii-db-querytrait.html">yii\db\QueryTrait</a></td>
    </tr>
            <tr class="inherited" id="$offset">
        <td><a href="yii-db-querytrait.html#$offset-detail">$offset</a></td>
        <td><a href="http://www.php.net/language.types.integer">integer</a></td>
        <td>Zero-based offset from where the records are to be returned.</td>
        <td><a href="yii-db-querytrait.html">yii\db\QueryTrait</a></td>
    </tr>
            <tr class="inherited" id="$orderBy">
        <td><a href="yii-db-querytrait.html#$orderBy-detail">$orderBy</a></td>
        <td><a href="http://www.php.net/language.types.array">array</a></td>
        <td>How to sort the query results.</td>
        <td><a href="yii-db-querytrait.html">yii\db\QueryTrait</a></td>
    </tr>
            <tr id="$params">
        <td><a href="yii-db-query.html#$params-detail">$params</a></td>
        <td><a href="http://www.php.net/language.types.array">array</a></td>
        <td>List of query parameter values indexed by parameter placeholders.</td>
        <td><a href="yii-db-query.html">yii\db\Query</a></td>
    </tr>
            <tr id="$select">
        <td><a href="yii-db-query.html#$select-detail">$select</a></td>
        <td><a href="http://www.php.net/language.types.array">array</a></td>
        <td>The columns being selected.</td>
        <td><a href="yii-db-query.html">yii\db\Query</a></td>
    </tr>
            <tr id="$selectOption">
        <td><a href="yii-db-query.html#$selectOption-detail">$selectOption</a></td>
        <td><a href="http://www.php.net/language.types.string">string</a></td>
        <td>Additional option that should be appended to the 'SELECT' keyword.</td>
        <td><a href="yii-db-query.html">yii\db\Query</a></td>
    </tr>
            <tr id="$union">
        <td><a href="yii-db-query.html#$union-detail">$union</a></td>
        <td><a href="http://www.php.net/language.types.array">array</a></td>
        <td>This is used to construct the UNION clause(s) in a SQL statement.</td>
        <td><a href="yii-db-query.html">yii\db\Query</a></td>
    </tr>
            <tr class="inherited" id="$where">
        <td><a href="yii-db-querytrait.html#$where-detail">$where</a></td>
        <td><a href="http://www.php.net/language.types.string">string</a>|<a href="http://www.php.net/language.types.array">array</a></td>
        <td>Query condition.</td>
        <td><a href="yii-db-querytrait.html">yii\db\QueryTrait</a></td>
    </tr>
    </table>
</div>

<a id="methods"></a>

<div class="summary doc-method">
<h2>Public Methods</h2>

<p><a href="#" class="toggle">Hide inherited methods</a></p>

<table class="summary-table table table-striped table-bordered table-hover">
<colgroup>
    <col class="col-method" />
    <col class="col-description" />
    <col class="col-defined" />
</colgroup>
<tr>
  <th>Method</th><th>Description</th><th>Defined By</th>
</tr>
        <tr class="inherited" id="__call()">
        <td><a href="yii-base-component.html#__call()-detail">__call()</a></td>
        <td>Calls the named method which is not a class method.</td>
        <td><a href="yii-base-component.html">yii\base\Component</a></td>
    </tr>
            <tr class="inherited" id="__clone()">
        <td><a href="yii-base-component.html#__clone()-detail">__clone()</a></td>
        <td>This method is called after the object is created by cloning an existing one.</td>
        <td><a href="yii-base-component.html">yii\base\Component</a></td>
    </tr>
            <tr class="inherited" id="__construct()">
        <td><a href="yii-base-object.html#__construct()-detail">__construct()</a></td>
        <td>Constructor.</td>
        <td><a href="yii-base-object.html">yii\base\Object</a></td>
    </tr>
            <tr class="inherited" id="__get()">
        <td><a href="yii-base-component.html#__get()-detail">__get()</a></td>
        <td>Returns the value of a component property.</td>
        <td><a href="yii-base-component.html">yii\base\Component</a></td>
    </tr>
            <tr class="inherited" id="__isset()">
        <td><a href="yii-base-component.html#__isset()-detail">__isset()</a></td>
        <td>Checks if a property is set, i.e. defined and not null.</td>
        <td><a href="yii-base-component.html">yii\base\Component</a></td>
    </tr>
            <tr class="inherited" id="__set()">
        <td><a href="yii-base-component.html#__set()-detail">__set()</a></td>
        <td>Sets the value of a component property.</td>
        <td><a href="yii-base-component.html">yii\base\Component</a></td>
    </tr>
            <tr class="inherited" id="__unset()">
        <td><a href="yii-base-component.html#__unset()-detail">__unset()</a></td>
        <td>Sets a component property to be null.</td>
        <td><a href="yii-base-component.html">yii\base\Component</a></td>
    </tr>
            <tr id="addGroupBy()">
        <td><a href="yii-db-query.html#addGroupBy()-detail">addGroupBy()</a></td>
        <td>Adds additional group-by columns to the existing ones.</td>
        <td><a href="yii-db-query.html">yii\db\Query</a></td>
    </tr>
            <tr class="inherited" id="addOrderBy()">
        <td><a href="yii-db-querytrait.html#addOrderBy()-detail">addOrderBy()</a></td>
        <td>Adds additional ORDER BY columns to the query.</td>
        <td><a href="yii-db-querytrait.html">yii\db\QueryTrait</a></td>
    </tr>
            <tr id="addParams()">
        <td><a href="yii-db-query.html#addParams()-detail">addParams()</a></td>
        <td>Adds additional parameters to be bound to the query.</td>
        <td><a href="yii-db-query.html">yii\db\Query</a></td>
    </tr>
            <tr id="addSelect()">
        <td><a href="yii-db-query.html#addSelect()-detail">addSelect()</a></td>
        <td>Add more columns to the SELECT part of the query.</td>
        <td><a href="yii-db-query.html">yii\db\Query</a></td>
    </tr>
            <tr id="all()">
        <td><a href="yii-db-query.html#all()-detail">all()</a></td>
        <td>Executes the query and returns all results as an array.</td>
        <td><a href="yii-db-query.html">yii\db\Query</a></td>
    </tr>
            <tr id="andFilterCompare()">
        <td><a href="yii-db-query.html#andFilterCompare()-detail">andFilterCompare()</a></td>
        <td>Adds a filtering condition for a specific column and allow the user to choose a filter operator.</td>
        <td><a href="yii-db-query.html">yii\db\Query</a></td>
    </tr>
            <tr class="inherited" id="andFilterWhere()">
        <td><a href="yii-db-querytrait.html#andFilterWhere()-detail">andFilterWhere()</a></td>
        <td>Adds an additional WHERE condition to the existing one but ignores <a href="yii-db-querytrait.html#isEmpty()-detail">empty operands</a>.</td>
        <td><a href="yii-db-querytrait.html">yii\db\QueryTrait</a></td>
    </tr>
            <tr id="andHaving()">
        <td><a href="yii-db-query.html#andHaving()-detail">andHaving()</a></td>
        <td>Adds an additional HAVING condition to the existing one.</td>
        <td><a href="yii-db-query.html">yii\db\Query</a></td>
    </tr>
            <tr id="andWhere()">
        <td><a href="yii-db-query.html#andWhere()-detail">andWhere()</a></td>
        <td>Adds an additional WHERE condition to the existing one.</td>
        <td><a href="yii-db-query.html">yii\db\Query</a></td>
    </tr>
            <tr class="inherited" id="attachBehavior()">
        <td><a href="yii-base-component.html#attachBehavior()-detail">attachBehavior()</a></td>
        <td>Attaches a behavior to this component.</td>
        <td><a href="yii-base-component.html">yii\base\Component</a></td>
    </tr>
            <tr class="inherited" id="attachBehaviors()">
        <td><a href="yii-base-component.html#attachBehaviors()-detail">attachBehaviors()</a></td>
        <td>Attaches a list of behaviors to the component.</td>
        <td><a href="yii-base-component.html">yii\base\Component</a></td>
    </tr>
            <tr id="average()">
        <td><a href="yii-db-query.html#average()-detail">average()</a></td>
        <td>Returns the average of the specified column values.</td>
        <td><a href="yii-db-query.html">yii\db\Query</a></td>
    </tr>
            <tr id="batch()">
        <td><a href="yii-db-query.html#batch()-detail">batch()</a></td>
        <td>Starts a batch query.</td>
        <td><a href="yii-db-query.html">yii\db\Query</a></td>
    </tr>
            <tr class="inherited" id="behaviors()">
        <td><a href="yii-base-component.html#behaviors()-detail">behaviors()</a></td>
        <td>Returns a list of behaviors that this component should behave as.</td>
        <td><a href="yii-base-component.html">yii\base\Component</a></td>
    </tr>
            <tr class="inherited" id="canGetProperty()">
        <td><a href="yii-base-component.html#canGetProperty()-detail">canGetProperty()</a></td>
        <td>Returns a value indicating whether a property can be read.</td>
        <td><a href="yii-base-component.html">yii\base\Component</a></td>
    </tr>
            <tr class="inherited" id="canSetProperty()">
        <td><a href="yii-base-component.html#canSetProperty()-detail">canSetProperty()</a></td>
        <td>Returns a value indicating whether a property can be set.</td>
        <td><a href="yii-base-component.html">yii\base\Component</a></td>
    </tr>
            <tr class="inherited" id="className()">
        <td><a href="yii-base-object.html#className()-detail">className()</a></td>
        <td>Returns the fully qualified name of this class.</td>
        <td><a href="yii-base-object.html">yii\base\Object</a></td>
    </tr>
            <tr id="column()">
        <td><a href="yii-db-query.html#column()-detail">column()</a></td>
        <td>Executes the query and returns the first column of the result.</td>
        <td><a href="yii-db-query.html">yii\db\Query</a></td>
    </tr>
            <tr id="count()">
        <td><a href="yii-db-query.html#count()-detail">count()</a></td>
        <td>Returns the number of records.</td>
        <td><a href="yii-db-query.html">yii\db\Query</a></td>
    </tr>
            <tr id="create()">
        <td><a href="yii-db-query.html#create()-detail">create()</a></td>
        <td>Creates a new Query object and copies its property values from an existing one.</td>
        <td><a href="yii-db-query.html">yii\db\Query</a></td>
    </tr>
            <tr id="createCommand()">
        <td><a href="yii-db-query.html#createCommand()-detail">createCommand()</a></td>
        <td>Creates a DB command that can be used to execute this query.</td>
        <td><a href="yii-db-query.html">yii\db\Query</a></td>
    </tr>
            <tr class="inherited" id="detachBehavior()">
        <td><a href="yii-base-component.html#detachBehavior()-detail">detachBehavior()</a></td>
        <td>Detaches a behavior from the component.</td>
        <td><a href="yii-base-component.html">yii\base\Component</a></td>
    </tr>
            <tr class="inherited" id="detachBehaviors()">
        <td><a href="yii-base-component.html#detachBehaviors()-detail">detachBehaviors()</a></td>
        <td>Detaches all behaviors from the component.</td>
        <td><a href="yii-base-component.html">yii\base\Component</a></td>
    </tr>
            <tr id="distinct()">
        <td><a href="yii-db-query.html#distinct()-detail">distinct()</a></td>
        <td>Sets the value indicating whether to SELECT DISTINCT or not.</td>
        <td><a href="yii-db-query.html">yii\db\Query</a></td>
    </tr>
            <tr id="each()">
        <td><a href="yii-db-query.html#each()-detail">each()</a></td>
        <td>Starts a batch query and retrieves data row by row.</td>
        <td><a href="yii-db-query.html">yii\db\Query</a></td>
    </tr>
            <tr class="inherited" id="ensureBehaviors()">
        <td><a href="yii-base-component.html#ensureBehaviors()-detail">ensureBehaviors()</a></td>
        <td>Makes sure that the behaviors declared in <a href="yii-base-component.html#behaviors()-detail">behaviors()</a> are attached to this component.</td>
        <td><a href="yii-base-component.html">yii\base\Component</a></td>
    </tr>
            <tr id="exists()">
        <td><a href="yii-db-query.html#exists()-detail">exists()</a></td>
        <td>Returns a value indicating whether the query result contains any row of data.</td>
        <td><a href="yii-db-query.html">yii\db\Query</a></td>
    </tr>
                <tr class="inherited" id="filterWhere()">
        <td><a href="yii-db-querytrait.html#filterWhere()-detail">filterWhere()</a></td>
        <td>Sets the WHERE part of the query but ignores <a href="yii-db-querytrait.html#isEmpty()-detail">empty operands</a>.</td>
        <td><a href="yii-db-querytrait.html">yii\db\QueryTrait</a></td>
    </tr>
            <tr id="from()">
        <td><a href="yii-db-query.html#from()-detail">from()</a></td>
        <td>Sets the FROM part of the query.</td>
        <td><a href="yii-db-query.html">yii\db\Query</a></td>
    </tr>
            <tr class="inherited" id="getBehavior()">
        <td><a href="yii-base-component.html#getBehavior()-detail">getBehavior()</a></td>
        <td>Returns the named behavior object.</td>
        <td><a href="yii-base-component.html">yii\base\Component</a></td>
    </tr>
            <tr class="inherited" id="getBehaviors()">
        <td><a href="yii-base-component.html#getBehaviors()-detail">getBehaviors()</a></td>
        <td>Returns all behaviors attached to this component.</td>
        <td><a href="yii-base-component.html">yii\base\Component</a></td>
    </tr>
            <tr id="groupBy()">
        <td><a href="yii-db-query.html#groupBy()-detail">groupBy()</a></td>
        <td>Sets the GROUP BY part of the query.</td>
        <td><a href="yii-db-query.html">yii\db\Query</a></td>
    </tr>
            <tr class="inherited" id="hasEventHandlers()">
        <td><a href="yii-base-component.html#hasEventHandlers()-detail">hasEventHandlers()</a></td>
        <td>Returns a value indicating whether there is any handler attached to the named event.</td>
        <td><a href="yii-base-component.html">yii\base\Component</a></td>
    </tr>
            <tr class="inherited" id="hasMethod()">
        <td><a href="yii-base-component.html#hasMethod()-detail">hasMethod()</a></td>
        <td>Returns a value indicating whether a method is defined.</td>
        <td><a href="yii-base-component.html">yii\base\Component</a></td>
    </tr>
            <tr class="inherited" id="hasProperty()">
        <td><a href="yii-base-component.html#hasProperty()-detail">hasProperty()</a></td>
        <td>Returns a value indicating whether a property is defined for this component.</td>
        <td><a href="yii-base-component.html">yii\base\Component</a></td>
    </tr>
            <tr id="having()">
        <td><a href="yii-db-query.html#having()-detail">having()</a></td>
        <td>Sets the HAVING part of the query.</td>
        <td><a href="yii-db-query.html">yii\db\Query</a></td>
    </tr>
            <tr class="inherited" id="indexBy()">
        <td><a href="yii-db-querytrait.html#indexBy()-detail">indexBy()</a></td>
        <td>Sets the <a href="yii-db-querytrait.html#indexBy()-detail">indexBy()</a> property.</td>
        <td><a href="yii-db-querytrait.html">yii\db\QueryTrait</a></td>
    </tr>
            <tr class="inherited" id="init()">
        <td><a href="yii-base-object.html#init()-detail">init()</a></td>
        <td>Initializes the object.</td>
        <td><a href="yii-base-object.html">yii\base\Object</a></td>
    </tr>
            <tr id="innerJoin()">
        <td><a href="yii-db-query.html#innerJoin()-detail">innerJoin()</a></td>
        <td>Appends an INNER JOIN part to the query.</td>
        <td><a href="yii-db-query.html">yii\db\Query</a></td>
    </tr>
                <tr id="join()">
        <td><a href="yii-db-query.html#join()-detail">join()</a></td>
        <td>Appends a JOIN part to the query.</td>
        <td><a href="yii-db-query.html">yii\db\Query</a></td>
    </tr>
            <tr id="leftJoin()">
        <td><a href="yii-db-query.html#leftJoin()-detail">leftJoin()</a></td>
        <td>Appends a LEFT OUTER JOIN part to the query.</td>
        <td><a href="yii-db-query.html">yii\db\Query</a></td>
    </tr>
            <tr class="inherited" id="limit()">
        <td><a href="yii-db-querytrait.html#limit()-detail">limit()</a></td>
        <td>Sets the LIMIT part of the query.</td>
        <td><a href="yii-db-querytrait.html">yii\db\QueryTrait</a></td>
    </tr>
            <tr id="max()">
        <td><a href="yii-db-query.html#max()-detail">max()</a></td>
        <td>Returns the maximum of the specified column values.</td>
        <td><a href="yii-db-query.html">yii\db\Query</a></td>
    </tr>
            <tr id="min()">
        <td><a href="yii-db-query.html#min()-detail">min()</a></td>
        <td>Returns the minimum of the specified column values.</td>
        <td><a href="yii-db-query.html">yii\db\Query</a></td>
    </tr>
                <tr class="inherited" id="off()">
        <td><a href="yii-base-component.html#off()-detail">off()</a></td>
        <td>Detaches an existing event handler from this component.</td>
        <td><a href="yii-base-component.html">yii\base\Component</a></td>
    </tr>
            <tr class="inherited" id="offset()">
        <td><a href="yii-db-querytrait.html#offset()-detail">offset()</a></td>
        <td>Sets the OFFSET part of the query.</td>
        <td><a href="yii-db-querytrait.html">yii\db\QueryTrait</a></td>
    </tr>
            <tr class="inherited" id="on()">
        <td><a href="yii-base-component.html#on()-detail">on()</a></td>
        <td>Attaches an event handler to an event.</td>
        <td><a href="yii-base-component.html">yii\base\Component</a></td>
    </tr>
            <tr id="one()">
        <td><a href="yii-db-query.html#one()-detail">one()</a></td>
        <td>Executes the query and returns a single row of result.</td>
        <td><a href="yii-db-query.html">yii\db\Query</a></td>
    </tr>
            <tr class="inherited" id="orFilterWhere()">
        <td><a href="yii-db-querytrait.html#orFilterWhere()-detail">orFilterWhere()</a></td>
        <td>Adds an additional WHERE condition to the existing one but ignores <a href="yii-db-querytrait.html#isEmpty()-detail">empty operands</a>.</td>
        <td><a href="yii-db-querytrait.html">yii\db\QueryTrait</a></td>
    </tr>
            <tr id="orHaving()">
        <td><a href="yii-db-query.html#orHaving()-detail">orHaving()</a></td>
        <td>Adds an additional HAVING condition to the existing one.</td>
        <td><a href="yii-db-query.html">yii\db\Query</a></td>
    </tr>
            <tr id="orWhere()">
        <td><a href="yii-db-query.html#orWhere()-detail">orWhere()</a></td>
        <td>Adds an additional WHERE condition to the existing one.</td>
        <td><a href="yii-db-query.html">yii\db\Query</a></td>
    </tr>
            <tr class="inherited" id="orderBy()">
        <td><a href="yii-db-querytrait.html#orderBy()-detail">orderBy()</a></td>
        <td>Sets the ORDER BY part of the query.</td>
        <td><a href="yii-db-querytrait.html">yii\db\QueryTrait</a></td>
    </tr>
            <tr id="params()">
        <td><a href="yii-db-query.html#params()-detail">params()</a></td>
        <td>Sets the parameters to be bound to the query.</td>
        <td><a href="yii-db-query.html">yii\db\Query</a></td>
    </tr>
            <tr id="populate()">
        <td><a href="yii-db-query.html#populate()-detail">populate()</a></td>
        <td>Converts the raw query results into the format as specified by this query.</td>
        <td><a href="yii-db-query.html">yii\db\Query</a></td>
    </tr>
            <tr id="prepare()">
        <td><a href="yii-db-query.html#prepare()-detail">prepare()</a></td>
        <td>Prepares for building SQL.</td>
        <td><a href="yii-db-query.html">yii\db\Query</a></td>
    </tr>
                <tr id="rightJoin()">
        <td><a href="yii-db-query.html#rightJoin()-detail">rightJoin()</a></td>
        <td>Appends a RIGHT OUTER JOIN part to the query.</td>
        <td><a href="yii-db-query.html">yii\db\Query</a></td>
    </tr>
            <tr id="scalar()">
        <td><a href="yii-db-query.html#scalar()-detail">scalar()</a></td>
        <td>Returns the query result as a scalar value.</td>
        <td><a href="yii-db-query.html">yii\db\Query</a></td>
    </tr>
            <tr id="select()">
        <td><a href="yii-db-query.html#select()-detail">select()</a></td>
        <td>Sets the SELECT part of the query.</td>
        <td><a href="yii-db-query.html">yii\db\Query</a></td>
    </tr>
            <tr id="sum()">
        <td><a href="yii-db-query.html#sum()-detail">sum()</a></td>
        <td>Returns the sum of the specified column values.</td>
        <td><a href="yii-db-query.html">yii\db\Query</a></td>
    </tr>
            <tr class="inherited" id="trigger()">
        <td><a href="yii-base-component.html#trigger()-detail">trigger()</a></td>
        <td>Triggers an event.</td>
        <td><a href="yii-base-component.html">yii\base\Component</a></td>
    </tr>
            <tr id="union()">
        <td><a href="yii-db-query.html#union()-detail">union()</a></td>
        <td>Appends a SQL statement using UNION operator.</td>
        <td><a href="yii-db-query.html">yii\db\Query</a></td>
    </tr>
            <tr id="where()">
        <td><a href="yii-db-query.html#where()-detail">where()</a></td>
        <td>Sets the WHERE part of the query.</td>
        <td><a href="yii-db-query.html">yii\db\Query</a></td>
    </tr>
    </table>
</div>

<div class="summary doc-method">
<h2>Protected Methods</h2>

<p><a href="#" class="toggle">Hide inherited methods</a></p>

<table class="summary-table table table-striped table-bordered table-hover">
<colgroup>
    <col class="col-method" />
    <col class="col-description" />
    <col class="col-defined" />
</colgroup>
<tr>
  <th>Method</th><th>Description</th><th>Defined By</th>
</tr>
                                                                                                                                                <tr class="inherited" id="filterCondition()">
        <td><a href="yii-db-querytrait.html#filterCondition()-detail">filterCondition()</a></td>
        <td>Removes <a href="yii-db-querytrait.html#isEmpty()-detail">empty operands</a> from the given query condition.</td>
        <td><a href="yii-db-querytrait.html">yii\db\QueryTrait</a></td>
    </tr>
                                                            <tr class="inherited" id="isEmpty()">
        <td><a href="yii-db-querytrait.html#isEmpty()-detail">isEmpty()</a></td>
        <td>Returns a value indicating whether the give value is "empty".</td>
        <td><a href="yii-db-querytrait.html">yii\db\QueryTrait</a></td>
    </tr>
                                <tr class="inherited" id="normalizeOrderBy()">
        <td><a href="yii-db-querytrait.html#normalizeOrderBy()-detail">normalizeOrderBy()</a></td>
        <td>Normalizes format of ORDER BY data</td>
        <td><a href="yii-db-querytrait.html">yii\db\QueryTrait</a></td>
    </tr>
                                                        <tr id="queryScalar()">
        <td><a href="yii-db-query.html#queryScalar()-detail">queryScalar()</a></td>
        <td>Queries a scalar value by setting <a href="yii-db-query.html#select()-detail">select()</a> first.</td>
        <td><a href="yii-db-query.html">yii\db\Query</a></td>
    </tr>
                                </table>
</div>

<a id="events"></a>

<a id="constants"></a>

<h2>Property Details</h2>

<div class="property-doc">

    <div class="detail-header h3" id="$distinct-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-db-query.html#$distinct-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2/edit/master/framework/db/Query.php#L65" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2/blob/master/framework/db/Query.php#L65" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        $distinct        <span class="detail-header-tag small">
            public                                                property
                    </span>
    </div>

    <div class="doc-description">
        <p>Whether to select distinct rows of data only. If this is set true,
the SELECT clause would be changed to SELECT DISTINCT.</p>

            </div>

    <div class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="http://www.php.net/language.types.boolean">boolean</a></span> <a href="yii-db-query.html#$distinct-detail">$distinct</a> <span style="color: #0000BB"></span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">null</span></div>


    <div class="detail-header h3" id="$from-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-db-query.html#$from-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2/edit/master/framework/db/Query.php#L71" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2/blob/master/framework/db/Query.php#L71" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        $from        <span class="detail-header-tag small">
            public                                                property
                    </span>
    </div>

    <div class="doc-description">
        <p>The table(s) to be selected from. For example, <code>['user', 'post']</code>.
This is used to construct the FROM clause in a SQL statement.</p>

        <p>See also <a href="yii-db-query.html#from()-detail">from()</a>.</p>    </div>

    <div class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="http://www.php.net/language.types.array">array</a></span> <a href="yii-db-query.html#$from-detail">$from</a> <span style="color: #0000BB"></span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">null</span></div>


    <div class="detail-header h3" id="$groupBy-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-db-query.html#$groupBy-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2/edit/master/framework/db/Query.php#L76" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2/blob/master/framework/db/Query.php#L76" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        $groupBy        <span class="detail-header-tag small">
            public                                                property
                    </span>
    </div>

    <div class="doc-description">
        <p>How to group the query results. For example, <code>['company', 'department']</code>.
This is used to construct the GROUP BY clause in a SQL statement.</p>

            </div>

    <div class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="http://www.php.net/language.types.array">array</a></span> <a href="yii-db-query.html#$groupBy-detail">$groupBy</a> <span style="color: #0000BB"></span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">null</span></div>


    <div class="detail-header h3" id="$having-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-db-query.html#$having-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2/edit/master/framework/db/Query.php#L99" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2/blob/master/framework/db/Query.php#L99" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        $having        <span class="detail-header-tag small">
            public                                                property
                    </span>
    </div>

    <div class="doc-description">
        <p>The condition to be applied in the GROUP BY clause.
It can be either a string or an array. Please refer to <a href="yii-db-query.html#where()-detail">where()</a> on how to specify the condition.</p>

            </div>

    <div class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="http://www.php.net/language.types.string">string</a>|<a href="http://www.php.net/language.types.array">array</a></span> <a href="yii-db-query.html#$having-detail">$having</a> <span style="color: #0000BB"></span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">null</span></div>


    <div class="detail-header h3" id="$join-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-db-query.html#$join-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2/edit/master/framework/db/Query.php#L94" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2/blob/master/framework/db/Query.php#L94" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        $join        <span class="detail-header-tag small">
            public                                                property
                    </span>
    </div>

    <div class="doc-description">
        <p>How to join with other tables. Each array element represents the specification
of one join which has the following structure:</p>
<pre><code class="hljs php language-php">[<span class="hljs-variable">$joinType</span>, <span class="hljs-variable">$tableName</span>, <span class="hljs-variable">$joinCondition</span>]
</code></pre>
<p>For example,</p>
<pre><code class="hljs php language-php">[
    [<span class="hljs-string">'INNER JOIN'</span>, <span class="hljs-string">'user'</span>, <span class="hljs-string">'user.id = author_id'</span>],
    [<span class="hljs-string">'LEFT JOIN'</span>, <span class="hljs-string">'team'</span>, <span class="hljs-string">'team.id = team_id'</span>],
]
</code></pre>

            </div>

    <div class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="http://www.php.net/language.types.array">array</a></span> <a href="yii-db-query.html#$join-detail">$join</a> <span style="color: #0000BB"></span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">null</span></div>


    <div class="detail-header h3" id="$params-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-db-query.html#$params-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2/edit/master/framework/db/Query.php#L112" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2/blob/master/framework/db/Query.php#L112" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        $params        <span class="detail-header-tag small">
            public                                                property
                    </span>
    </div>

    <div class="doc-description">
        <p>List of query parameter values indexed by parameter placeholders.
For example, <code>[':name' =&gt; 'Dan', ':age' =&gt; 31]</code>.</p>

            </div>

    <div class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="http://www.php.net/language.types.array">array</a></span> <a href="yii-db-query.html#$params-detail">$params</a> <span style="color: #0000BB"></span><span style="color: #007700">=&nbsp;[]</span></div>


    <div class="detail-header h3" id="$select-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-db-query.html#$select-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2/edit/master/framework/db/Query.php#L55" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2/blob/master/framework/db/Query.php#L55" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        $select        <span class="detail-header-tag small">
            public                                                property
                    </span>
    </div>

    <div class="doc-description">
        <p>The columns being selected. For example, <code>['id', 'name']</code>.
This is used to construct the SELECT clause in a SQL statement. If not set, it means selecting all columns.</p>

        <p>See also <a href="yii-db-query.html#select()-detail">select()</a>.</p>    </div>

    <div class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="http://www.php.net/language.types.array">array</a></span> <a href="yii-db-query.html#$select-detail">$select</a> <span style="color: #0000BB"></span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">null</span></div>


    <div class="detail-header h3" id="$selectOption-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-db-query.html#$selectOption-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2/edit/master/framework/db/Query.php#L60" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2/blob/master/framework/db/Query.php#L60" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        $selectOption        <span class="detail-header-tag small">
            public                                                property
                    </span>
    </div>

    <div class="doc-description">
        <p>Additional option that should be appended to the 'SELECT' keyword. For example,
in MySQL, the option 'SQL_CALC_FOUND_ROWS' can be used.</p>

            </div>

    <div class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="http://www.php.net/language.types.string">string</a></span> <a href="yii-db-query.html#$selectOption-detail">$selectOption</a> <span style="color: #0000BB"></span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">null</span></div>


    <div class="detail-header h3" id="$union-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-db-query.html#$union-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2/edit/master/framework/db/Query.php#L107" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2/blob/master/framework/db/Query.php#L107" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        $union        <span class="detail-header-tag small">
            public                                                property
                    </span>
    </div>

    <div class="doc-description">
        <p>This is used to construct the UNION clause(s) in a SQL statement.
Each array element is an array of the following structure:</p>
<ul>
<li><code>query</code>: either a string or a <a href="yii-db-query.html">yii\db\Query</a> object representing a query</li>
<li><code>all</code>: boolean, whether it should be <code>UNION ALL</code> or <code>UNION</code></li>
</ul>

            </div>

    <div class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="http://www.php.net/language.types.array">array</a></span> <a href="yii-db-query.html#$union-detail">$union</a> <span style="color: #0000BB"></span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">null</span></div>

</div>
<h2>Method Details</h2>

<div class="method-doc">

    <div class="detail-header h3" id="addGroupBy()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-db-query.html#addGroupBy()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2/edit/master/framework/db/Query.php#L770" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2/blob/master/framework/db/Query.php#L770" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        addGroupBy()
        <span class="detail-header-tag small">
            public                                    method
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Adds additional group-by columns to the existing ones.</strong></p>

        
        <p>See also <a href="yii-db-query.html#groupBy()-detail">groupBy()</a>.</p>    </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="yii-db-query.html">$this</a></span> <strong><a href="yii-db-query.html#addGroupBy()-detail">addGroupBy</a></strong> ( <span style="color: #0000BB">$columns</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$columns</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.string">string</a>|<a href="http://www.php.net/language.types.array">array</a></td>
                  <td class="param-desc-col"><p>Additional columns to be grouped by.
Columns can be specified in either a string (e.g. "id, name") or an array (e.g. ['id', 'name']).
The method will automatically quote the column names unless a column contains some parenthesis
(which means the column contains a DB expression).</p>
<p>Note that if your group-by is an expression containing commas, you should always use an array
to represent the group-by information. Otherwise, the method will not be able to correctly determine
the group-by columns.</p>
<p>Since version 2.0.7, an <a href="yii-db-expression.html">yii\db\Expression</a> object can be passed to specify the GROUP BY part explicitly in plain SQL.</p>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col"><a href="yii-db-query.html">$this</a></td>
                  <td class="param-desc-col"><p>The query object itself</p>
</td>
                </tr>
                                    </table>

<!--	-->

    <div class="detail-header h3" id="addParams()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-db-query.html#addParams()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2/edit/master/framework/db/Query.php#L875" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2/blob/master/framework/db/Query.php#L875" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        addParams()
        <span class="detail-header-tag small">
            public                                    method
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Adds additional parameters to be bound to the query.</strong></p>

        
        <p>See also <a href="yii-db-query.html#params()-detail">params()</a>.</p>    </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="yii-db-query.html">$this</a></span> <strong><a href="yii-db-query.html#addParams()-detail">addParams</a></strong> ( <span style="color: #0000BB">$params</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$params</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.array">array</a></td>
                  <td class="param-desc-col"><p>List of query parameter values indexed by parameter placeholders.
For example, <code>[':name' =&gt; 'Dan', ':age' =&gt; 31]</code>.</p>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col"><a href="yii-db-query.html">$this</a></td>
                  <td class="param-desc-col"><p>The query object itself</p>
</td>
                </tr>
                                    </table>

<!--	-->

    <div class="detail-header h3" id="addSelect()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-db-query.html#addSelect()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2/edit/master/framework/db/Query.php#L451" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2/blob/master/framework/db/Query.php#L451" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        addSelect()
        <span class="detail-header-tag small">
            public                                    method
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Add more columns to the SELECT part of the query.</strong></p>

        <p>Note, that if <a href="yii-db-query.html#select()-detail">select()</a> has not been specified before, you should include <code>*</code> explicitly
if you want to select all remaining columns too:</p>
<pre><code class="hljs php language-php"><span class="hljs-variable">$query</span>-&gt;addSelect([<span class="hljs-string">"*"</span>, <span class="hljs-string">"CONCAT(first_name, ' ', last_name) AS full_name"</span>])-&gt;one();
</code></pre>

        <p>See also <a href="yii-db-query.html#select()-detail">select()</a>.</p>    </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="yii-db-query.html">$this</a></span> <strong><a href="yii-db-query.html#addSelect()-detail">addSelect</a></strong> ( <span style="color: #0000BB">$columns</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$columns</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.string">string</a>|<a href="http://www.php.net/language.types.array">array</a>|<a href="yii-db-expression.html">yii\db\Expression</a></td>
                  <td class="param-desc-col"><p>The columns to add to the select. See <a href="yii-db-query.html#select()-detail">select()</a> for more
details about the format of this parameter.</p>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col"><a href="yii-db-query.html">$this</a></td>
                  <td class="param-desc-col"><p>The query object itself</p>
</td>
                </tr>
                                    </table>

<!--	-->

    <div class="detail-header h3" id="all()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-db-query.html#all()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2/edit/master/framework/db/Query.php#L208" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2/blob/master/framework/db/Query.php#L208" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        all()
        <span class="detail-header-tag small">
            public                                    method
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Executes the query and returns all results as an array.</strong></p>

        
            </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="http://www.php.net/language.types.array">array</a></span> <strong><a href="yii-db-query.html#all()-detail">all</a></strong> ( <span style="color: #0000BB">$db&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">null</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$db</span></td>
                  <td class="param-type-col"><a href="yii-db-connection.html">yii\db\Connection</a></td>
                  <td class="param-desc-col"><p>The database connection used to generate the SQL statement.
If this parameter is not given, the <code>db</code> application component will be used.</p>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.array">array</a></td>
                  <td class="param-desc-col"><p>The query results. If the query results in nothing, an empty array will be returned.</p>
</td>
                </tr>
                                    </table>

<!--	-->

    <div class="detail-header h3" id="andFilterCompare()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-db-query.html#andFilterCompare()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2/edit/master/framework/db/Query.php#L610" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2/blob/master/framework/db/Query.php#L610" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        andFilterCompare()
        <span class="detail-header-tag small">
            public                                    method
                            (available since version 2.0.8)
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Adds a filtering condition for a specific column and allow the user to choose a filter operator.</strong></p>

        <p>It adds an additional WHERE condition for the given field and determines the comparison operator
based on the first few characters of the given value.
The condition is added in the same way as in <a href="yii-db-querytrait.html#andFilterWhere()-detail">andFilterWhere()</a> so <a href="yii-db-querytrait.html#isEmpty()-detail">empty values</a> are ignored.
The new condition and the existing one will be joined using the 'AND' operator.</p>
<p>The comparison operator is intelligently determined based on the first few characters in the given value.
In particular, it recognizes the following operators if they appear as the leading characters in the given value:</p>
<ul>
<li><code>&lt;</code>: the column must be less than the given value.</li>
<li><code>&gt;</code>: the column must be greater than the given value.</li>
<li><code>&lt;=</code>: the column must be less than or equal to the given value.</li>
<li><code>&gt;=</code>: the column must be greater than or equal to the given value.</li>
<li><code>&lt;&gt;</code>: the column must not be the same as the given value.</li>
<li><code>=</code>: the column must be equal to the given value.</li>
<li>If none of the above operators is detected, the <code>$defaultOperator</code> will be used.</li>
</ul>

            </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="yii-db-query.html">$this</a></span> <strong><a href="yii-db-query.html#andFilterCompare()-detail">andFilterCompare</a></strong> ( <span style="color: #0000BB">$name</span>, <span style="color: #0000BB">$value</span>, <span style="color: #0000BB">$defaultOperator&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'='</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$name</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.string">string</a></td>
                  <td class="param-desc-col"><p>The column name.</p>
</td>
                </tr>
                            <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$value</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.string">string</a></td>
                  <td class="param-desc-col"><p>The column value optionally prepended with the comparison operator.</p>
</td>
                </tr>
                            <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$defaultOperator</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.string">string</a></td>
                  <td class="param-desc-col"><p>The operator to use, when no operator is given in <code>$value</code>.
Defaults to <code>=</code>, performing an exact match.</p>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col"><a href="yii-db-query.html">$this</a></td>
                  <td class="param-desc-col"><p>The query object itself</p>
</td>
                </tr>
                                    </table>

<!--	-->

    <div class="detail-header h3" id="andHaving()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-db-query.html#andHaving()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2/edit/master/framework/db/Query.php#L811" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2/blob/master/framework/db/Query.php#L811" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        andHaving()
        <span class="detail-header-tag small">
            public                                    method
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Adds an additional HAVING condition to the existing one.</strong></p>

        <p>The new condition and the existing one will be joined using the 'AND' operator.</p>

        <p>See also:</p><ul><li><a href="yii-db-query.html#having()-detail">having()</a></li><li><a href="yii-db-query.html#orHaving()-detail">orHaving()</a></li></ul>    </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="yii-db-query.html">$this</a></span> <strong><a href="yii-db-query.html#andHaving()-detail">andHaving</a></strong> ( <span style="color: #0000BB">$condition</span>, <span style="color: #0000BB">$params&nbsp;</span><span style="color: #007700">=&nbsp;[]</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$condition</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.string">string</a>|<a href="http://www.php.net/language.types.array">array</a>|<a href="yii-db-expression.html">yii\db\Expression</a></td>
                  <td class="param-desc-col"><p>The new HAVING condition. Please refer to <a href="yii-db-query.html#where()-detail">where()</a>
on how to specify this parameter.</p>
</td>
                </tr>
                            <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$params</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.array">array</a></td>
                  <td class="param-desc-col"><p>The parameters (name =&gt; value) to be bound to the query.</p>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col"><a href="yii-db-query.html">$this</a></td>
                  <td class="param-desc-col"><p>The query object itself</p>
</td>
                </tr>
                                    </table>

<!--	-->

    <div class="detail-header h3" id="andWhere()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-db-query.html#andWhere()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2/edit/master/framework/db/Query.php#L552" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2/blob/master/framework/db/Query.php#L552" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        andWhere()
        <span class="detail-header-tag small">
            public                                    method
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Adds an additional WHERE condition to the existing one.</strong></p>

        <p>The new condition and the existing one will be joined using the 'AND' operator.</p>

        <p>See also:</p><ul><li><a href="yii-db-query.html#where()-detail">where()</a></li><li><a href="yii-db-query.html#orWhere()-detail">orWhere()</a></li></ul>    </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="yii-db-query.html">$this</a></span> <strong><a href="yii-db-query.html#andWhere()-detail">andWhere</a></strong> ( <span style="color: #0000BB">$condition</span>, <span style="color: #0000BB">$params&nbsp;</span><span style="color: #007700">=&nbsp;[]</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$condition</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.string">string</a>|<a href="http://www.php.net/language.types.array">array</a>|<a href="yii-db-expression.html">yii\db\Expression</a></td>
                  <td class="param-desc-col"><p>The new WHERE condition. Please refer to <a href="yii-db-query.html#where()-detail">where()</a>
on how to specify this parameter.</p>
</td>
                </tr>
                            <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$params</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.array">array</a></td>
                  <td class="param-desc-col"><p>The parameters (name =&gt; value) to be bound to the query.</p>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col"><a href="yii-db-query.html">$this</a></td>
                  <td class="param-desc-col"><p>The query object itself</p>
</td>
                </tr>
                                    </table>

<!--	-->

    <div class="detail-header h3" id="average()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-db-query.html#average()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2/edit/master/framework/db/Query.php#L324" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2/blob/master/framework/db/Query.php#L324" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        average()
        <span class="detail-header-tag small">
            public                                    method
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Returns the average of the specified column values.</strong></p>

        
            </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type">mixed</span> <strong><a href="yii-db-query.html#average()-detail">average</a></strong> ( <span style="color: #0000BB">$q</span>, <span style="color: #0000BB">$db&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">null</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$q</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.string">string</a></td>
                  <td class="param-desc-col"><p>The column name or expression.
Make sure you properly <a href="./guide-db-dao.html#quoting-table-and-column-names">quote</a> column names in the expression.</p>
</td>
                </tr>
                            <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$db</span></td>
                  <td class="param-type-col"><a href="yii-db-connection.html">yii\db\Connection</a></td>
                  <td class="param-desc-col"><p>The database connection used to generate the SQL statement.
If this parameter is not given, the <code>db</code> application component will be used.</p>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col">mixed</td>
                  <td class="param-desc-col"><p>The average of the specified column values.</p>
</td>
                </tr>
                                    </table>

<!--	-->

    <div class="detail-header h3" id="batch()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-db-query.html#batch()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2/edit/master/framework/db/Query.php#L164" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2/blob/master/framework/db/Query.php#L164" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        batch()
        <span class="detail-header-tag small">
            public                                    method
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Starts a batch query.</strong></p>

        <p>A batch query supports fetching data in batches, which can keep the memory usage under a limit.
This method will return a <a href="yii-db-batchqueryresult.html">yii\db\BatchQueryResult</a> object which implements the <a href="http://www.php.net/class.iterator">Iterator</a> interface
and can be traversed to retrieve the data in batches.</p>
<p>For example,</p>
<pre><code class="hljs php language-php"><span class="hljs-variable">$query</span> = (<span class="hljs-keyword">new</span> Query)-&gt;from(<span class="hljs-string">'user'</span>);
<span class="hljs-keyword">foreach</span> (<span class="hljs-variable">$query</span>-&gt;batch() <span class="hljs-keyword">as</span> <span class="hljs-variable">$rows</span>) {
    <span class="hljs-comment">// $rows is an array of 10 or fewer rows from user table</span>
}
</code></pre>

            </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="yii-db-batchqueryresult.html">yii\db\BatchQueryResult</a></span> <strong><a href="yii-db-query.html#batch()-detail">batch</a></strong> ( <span style="color: #0000BB">$batchSize&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">100</span>, <span style="color: #0000BB">$db&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">null</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$batchSize</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.integer">integer</a></td>
                  <td class="param-desc-col"><p>The number of records to be fetched in each batch.</p>
</td>
                </tr>
                            <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$db</span></td>
                  <td class="param-type-col"><a href="yii-db-connection.html">yii\db\Connection</a></td>
                  <td class="param-desc-col"><p>The database connection. If not set, the "db" application component will be used.</p>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col"><a href="yii-db-batchqueryresult.html">yii\db\BatchQueryResult</a></td>
                  <td class="param-desc-col"><p>The batch query result. It implements the <a href="http://www.php.net/class.iterator">Iterator</a> interface
and can be traversed to retrieve the data in batches.</p>
</td>
                </tr>
                                    </table>

<!--	-->

    <div class="detail-header h3" id="column()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-db-query.html#column()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2/edit/master/framework/db/Query.php#L269" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2/blob/master/framework/db/Query.php#L269" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        column()
        <span class="detail-header-tag small">
            public                                    method
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Executes the query and returns the first column of the result.</strong></p>

        
            </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="http://www.php.net/language.types.array">array</a></span> <strong><a href="yii-db-query.html#column()-detail">column</a></strong> ( <span style="color: #0000BB">$db&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">null</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$db</span></td>
                  <td class="param-type-col"><a href="yii-db-connection.html">yii\db\Connection</a></td>
                  <td class="param-desc-col"><p>The database connection used to generate the SQL statement.
If this parameter is not given, the <code>db</code> application component will be used.</p>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.array">array</a></td>
                  <td class="param-desc-col"><p>The first column of the query result. An empty array is returned if the query results in nothing.</p>
</td>
                </tr>
                                    </table>

<!--	-->

    <div class="detail-header h3" id="count()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-db-query.html#count()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2/edit/master/framework/db/Query.php#L298" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2/blob/master/framework/db/Query.php#L298" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        count()
        <span class="detail-header-tag small">
            public                                    method
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Returns the number of records.</strong></p>

        
            </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="http://www.php.net/language.types.integer">integer</a>|<a href="http://www.php.net/language.types.string">string</a></span> <strong><a href="yii-db-query.html#count()-detail">count</a></strong> ( <span style="color: #0000BB">$q&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'*'</span>, <span style="color: #0000BB">$db&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">null</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$q</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.string">string</a></td>
                  <td class="param-desc-col"><p>The COUNT expression. Defaults to '*'.
Make sure you properly <a href="./guide-db-dao.html#quoting-table-and-column-names">quote</a> column names in the expression.</p>
</td>
                </tr>
                            <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$db</span></td>
                  <td class="param-type-col"><a href="yii-db-connection.html">yii\db\Connection</a></td>
                  <td class="param-desc-col"><p>The database connection used to generate the SQL statement.
If this parameter is not given (or null), the <code>db</code> application component will be used.</p>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.integer">integer</a>|<a href="http://www.php.net/language.types.string">string</a></td>
                  <td class="param-desc-col"><p>Number of records. The result may be a string depending on the
underlying database engine and to support integer values higher than a 32bit PHP integer can handle.</p>
</td>
                </tr>
                                    </table>

<!--	-->

    <div class="detail-header h3" id="create()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-db-query.html#create()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2/edit/master/framework/db/Query.php#L899" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2/blob/master/framework/db/Query.php#L899" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        create()
        <span class="detail-header-tag small">
            public                        static            method
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Creates a new Query object and copies its property values from an existing one.</strong></p>

        <p>The properties being copies are the ones to be used by query builders.</p>

            </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public static</span> <span class="signature-type"><a href="yii-db-query.html">yii\db\Query</a></span> <strong><a href="yii-db-query.html#create()-detail">create</a></strong> ( <span style="color: #0000BB">$from</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$from</span></td>
                  <td class="param-type-col"><a href="yii-db-query.html">yii\db\Query</a></td>
                  <td class="param-desc-col"><p>The source query object</p>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col"><a href="yii-db-query.html">yii\db\Query</a></td>
                  <td class="param-desc-col"><p>The new Query object</p>
</td>
                </tr>
                                    </table>

<!--	-->

    <div class="detail-header h3" id="createCommand()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-db-query.html#createCommand()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2/edit/master/framework/db/Query.php#L121" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2/blob/master/framework/db/Query.php#L121" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        createCommand()
        <span class="detail-header-tag small">
            public                                    method
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Creates a DB command that can be used to execute this query.</strong></p>

        
            </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="yii-db-command.html">yii\db\Command</a></span> <strong><a href="yii-db-query.html#createCommand()-detail">createCommand</a></strong> ( <span style="color: #0000BB">$db&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">null</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$db</span></td>
                  <td class="param-type-col"><a href="yii-db-connection.html">yii\db\Connection</a></td>
                  <td class="param-desc-col"><p>The database connection used to generate the SQL statement.
If this parameter is not given, the <code>db</code> application component will be used.</p>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col"><a href="yii-db-command.html">yii\db\Command</a></td>
                  <td class="param-desc-col"><p>The created DB command instance.</p>
</td>
                </tr>
                                    </table>

<!--	-->

    <div class="detail-header h3" id="distinct()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-db-query.html#distinct()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2/edit/master/framework/db/Query.php#L471" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2/blob/master/framework/db/Query.php#L471" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        distinct()
        <span class="detail-header-tag small">
            public                                    method
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Sets the value indicating whether to SELECT DISTINCT or not.</strong></p>

        
            </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="yii-db-query.html">$this</a></span> <strong><a href="yii-db-query.html#distinct()-detail">distinct</a></strong> ( <span style="color: #0000BB">$value&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">true</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$value</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.boolean">boolean</a></td>
                  <td class="param-desc-col"><p>Whether to SELECT DISTINCT or not.</p>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col"><a href="yii-db-query.html">$this</a></td>
                  <td class="param-desc-col"><p>The query object itself</p>
</td>
                </tr>
                                    </table>

<!--	-->

    <div class="detail-header h3" id="each()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-db-query.html#each()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2/edit/master/framework/db/Query.php#L191" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2/blob/master/framework/db/Query.php#L191" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        each()
        <span class="detail-header-tag small">
            public                                    method
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Starts a batch query and retrieves data row by row.</strong></p>

        <p>This method is similar to <a href="yii-db-query.html#batch()-detail">batch()</a> except that in each iteration of the result,
only one row of data is returned. For example,</p>
<pre><code class="hljs php language-php"><span class="hljs-variable">$query</span> = (<span class="hljs-keyword">new</span> Query)-&gt;from(<span class="hljs-string">'user'</span>);
<span class="hljs-keyword">foreach</span> (<span class="hljs-variable">$query</span>-&gt;each() <span class="hljs-keyword">as</span> <span class="hljs-variable">$row</span>) {
}
</code></pre>

            </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="yii-db-batchqueryresult.html">yii\db\BatchQueryResult</a></span> <strong><a href="yii-db-query.html#each()-detail">each</a></strong> ( <span style="color: #0000BB">$batchSize&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">100</span>, <span style="color: #0000BB">$db&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">null</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$batchSize</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.integer">integer</a></td>
                  <td class="param-desc-col"><p>The number of records to be fetched in each batch.</p>
</td>
                </tr>
                            <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$db</span></td>
                  <td class="param-type-col"><a href="yii-db-connection.html">yii\db\Connection</a></td>
                  <td class="param-desc-col"><p>The database connection. If not set, the "db" application component will be used.</p>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col"><a href="yii-db-batchqueryresult.html">yii\db\BatchQueryResult</a></td>
                  <td class="param-desc-col"><p>The batch query result. It implements the <a href="http://www.php.net/class.iterator">Iterator</a> interface
and can be traversed to retrieve the data in batches.</p>
</td>
                </tr>
                                    </table>

<!--	-->

    <div class="detail-header h3" id="exists()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-db-query.html#exists()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2/edit/master/framework/db/Query.php#L361" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2/blob/master/framework/db/Query.php#L361" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        exists()
        <span class="detail-header-tag small">
            public                                    method
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Returns a value indicating whether the query result contains any row of data.</strong></p>

        
            </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="http://www.php.net/language.types.boolean">boolean</a></span> <strong><a href="yii-db-query.html#exists()-detail">exists</a></strong> ( <span style="color: #0000BB">$db&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">null</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$db</span></td>
                  <td class="param-type-col"><a href="yii-db-connection.html">yii\db\Connection</a></td>
                  <td class="param-desc-col"><p>The database connection used to generate the SQL statement.
If this parameter is not given, the <code>db</code> application component will be used.</p>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.boolean">boolean</a></td>
                  <td class="param-desc-col"><p>Whether the query result contains any row of data.</p>
</td>
                </tr>
                                    </table>

<!--	-->

    <div class="detail-header h3" id="from()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-db-query.html#from()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2/edit/master/framework/db/Query.php#L509" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2/blob/master/framework/db/Query.php#L509" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        from()
        <span class="detail-header-tag small">
            public                                    method
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Sets the FROM part of the query.</strong></p>

        
            </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="yii-db-query.html">$this</a></span> <strong><a href="yii-db-query.html#from()-detail">from</a></strong> ( <span style="color: #0000BB">$tables</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$tables</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.string">string</a>|<a href="http://www.php.net/language.types.array">array</a></td>
                  <td class="param-desc-col"><p>The table(s) to be selected from. This can be either a string (e.g. <code>'user'</code>)
or an array (e.g. <code>['user', 'profile']</code>) specifying one or several table names.
Table names can contain schema prefixes (e.g. <code>'public.user'</code>) and/or table aliases (e.g. <code>'user u'</code>).
The method will automatically quote the table names unless it contains some parenthesis
(which means the table is given as a sub-query or DB expression).</p>
<p>When the tables are specified as an array, you may also use the array keys as the table aliases
(if a table does not need alias, do not use a string key).</p>
<p>Use a Query object to represent a sub-query. In this case, the corresponding array key will be used
as the alias for the sub-query.</p>
<p>Here are some examples:</p>
<pre><code class="hljs php language-php"><span class="hljs-comment">// SELECT * FROM  `user` `u`, `profile`;</span>
<span class="hljs-variable">$query</span> = (<span class="hljs-keyword">new</span> \yii\db\Query)-&gt;from([<span class="hljs-string">'u'</span> =&gt; <span class="hljs-string">'user'</span>, <span class="hljs-string">'profile'</span>]);

<span class="hljs-comment">// SELECT * FROM (SELECT * FROM `user` WHERE `active` = 1) `activeusers`;</span>
<span class="hljs-variable">$subquery</span> = (<span class="hljs-keyword">new</span> \yii\db\Query)-&gt;from(<span class="hljs-string">'user'</span>)-&gt;where([<span class="hljs-string">'active'</span> =&gt; <span class="hljs-keyword">true</span>])
<span class="hljs-variable">$query</span> = (<span class="hljs-keyword">new</span> \yii\db\Query)-&gt;from([<span class="hljs-string">'activeusers'</span> =&gt; <span class="hljs-variable">$subquery</span>]);

<span class="hljs-comment">// subquery can also be a string with plain SQL wrapped in parenthesis</span>
<span class="hljs-comment">// SELECT * FROM (SELECT * FROM `user` WHERE `active` = 1) `activeusers`;</span>
<span class="hljs-variable">$subquery</span> = <span class="hljs-string">"(SELECT * FROM `user` WHERE `active` = 1)"</span>;
<span class="hljs-variable">$query</span> = (<span class="hljs-keyword">new</span> \yii\db\Query)-&gt;from([<span class="hljs-string">'activeusers'</span> =&gt; <span class="hljs-variable">$subquery</span>]);
</code></pre>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col"><a href="yii-db-query.html">$this</a></td>
                  <td class="param-desc-col"><p>The query object itself</p>
</td>
                </tr>
                                    </table>

<!--	-->

    <div class="detail-header h3" id="groupBy()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-db-query.html#groupBy()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2/edit/master/framework/db/Query.php#L744" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2/blob/master/framework/db/Query.php#L744" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        groupBy()
        <span class="detail-header-tag small">
            public                                    method
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Sets the GROUP BY part of the query.</strong></p>

        
        <p>See also <a href="yii-db-query.html#addGroupBy()-detail">addGroupBy()</a>.</p>    </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="yii-db-query.html">$this</a></span> <strong><a href="yii-db-query.html#groupBy()-detail">groupBy</a></strong> ( <span style="color: #0000BB">$columns</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$columns</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.string">string</a>|<a href="http://www.php.net/language.types.array">array</a>|<a href="yii-db-expression.html">yii\db\Expression</a></td>
                  <td class="param-desc-col"><p>The columns to be grouped by.
Columns can be specified in either a string (e.g. "id, name") or an array (e.g. ['id', 'name']).
The method will automatically quote the column names unless a column contains some parenthesis
(which means the column contains a DB expression).</p>
<p>Note that if your group-by is an expression containing commas, you should always use an array
to represent the group-by information. Otherwise, the method will not be able to correctly determine
the group-by columns.</p>
<p>Since version 2.0.7, an <a href="yii-db-expression.html">yii\db\Expression</a> object can be passed to specify the GROUP BY part explicitly in plain SQL.</p>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col"><a href="yii-db-query.html">$this</a></td>
                  <td class="param-desc-col"><p>The query object itself</p>
</td>
                </tr>
                                    </table>

<!--	-->

    <div class="detail-header h3" id="having()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-db-query.html#having()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2/edit/master/framework/db/Query.php#L794" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2/blob/master/framework/db/Query.php#L794" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        having()
        <span class="detail-header-tag small">
            public                                    method
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Sets the HAVING part of the query.</strong></p>

        
        <p>See also:</p><ul><li><a href="yii-db-query.html#andHaving()-detail">andHaving()</a></li><li><a href="yii-db-query.html#orHaving()-detail">orHaving()</a></li></ul>    </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="yii-db-query.html">$this</a></span> <strong><a href="yii-db-query.html#having()-detail">having</a></strong> ( <span style="color: #0000BB">$condition</span>, <span style="color: #0000BB">$params&nbsp;</span><span style="color: #007700">=&nbsp;[]</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$condition</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.string">string</a>|<a href="http://www.php.net/language.types.array">array</a>|<a href="yii-db-expression.html">yii\db\Expression</a></td>
                  <td class="param-desc-col"><p>The conditions to be put after HAVING.
Please refer to <a href="yii-db-query.html#where()-detail">where()</a> on how to specify this parameter.</p>
</td>
                </tr>
                            <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$params</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.array">array</a></td>
                  <td class="param-desc-col"><p>The parameters (name =&gt; value) to be bound to the query.</p>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col"><a href="yii-db-query.html">$this</a></td>
                  <td class="param-desc-col"><p>The query object itself</p>
</td>
                </tr>
                                    </table>

<!--	-->

    <div class="detail-header h3" id="innerJoin()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-db-query.html#innerJoin()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2/edit/master/framework/db/Query.php#L675" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2/blob/master/framework/db/Query.php#L675" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        innerJoin()
        <span class="detail-header-tag small">
            public                                    method
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Appends an INNER JOIN part to the query.</strong></p>

        
            </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="yii-db-query.html">$this</a></span> <strong><a href="yii-db-query.html#innerJoin()-detail">innerJoin</a></strong> ( <span style="color: #0000BB">$table</span>, <span style="color: #0000BB">$on&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">''</span>, <span style="color: #0000BB">$params&nbsp;</span><span style="color: #007700">=&nbsp;[]</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$table</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.string">string</a>|<a href="http://www.php.net/language.types.array">array</a></td>
                  <td class="param-desc-col"><p>The table to be joined.</p>
<p>Use a string to represent the name of the table to be joined.
The table name can contain a schema prefix (e.g. 'public.user') and/or table alias (e.g. 'user u').
The method will automatically quote the table name unless it contains some parenthesis
(which means the table is given as a sub-query or DB expression).</p>
<p>Use an array to represent joining with a sub-query. The array must contain only one element.
The value must be a <a href="yii-db-query.html">yii\db\Query</a> object representing the sub-query while the corresponding key
represents the alias for the sub-query.</p>
</td>
                </tr>
                            <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$on</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.string">string</a>|<a href="http://www.php.net/language.types.array">array</a></td>
                  <td class="param-desc-col"><p>The join condition that should appear in the ON part.
Please refer to <a href="yii-db-query.html#join()-detail">join()</a> on how to specify this parameter.</p>
</td>
                </tr>
                            <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$params</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.array">array</a></td>
                  <td class="param-desc-col"><p>The parameters (name =&gt; value) to be bound to the query.</p>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col"><a href="yii-db-query.html">$this</a></td>
                  <td class="param-desc-col"><p>The query object itself</p>
</td>
                </tr>
                                    </table>

<!--	-->

    <div class="detail-header h3" id="join()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-db-query.html#join()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2/edit/master/framework/db/Query.php#L651" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2/blob/master/framework/db/Query.php#L651" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        join()
        <span class="detail-header-tag small">
            public                                    method
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Appends a JOIN part to the query.</strong></p>

        <p>The first parameter specifies what type of join it is.</p>

            </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="yii-db-query.html">$this</a></span> <strong><a href="yii-db-query.html#join()-detail">join</a></strong> ( <span style="color: #0000BB">$type</span>, <span style="color: #0000BB">$table</span>, <span style="color: #0000BB">$on&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">''</span>, <span style="color: #0000BB">$params&nbsp;</span><span style="color: #007700">=&nbsp;[]</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$type</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.string">string</a></td>
                  <td class="param-desc-col"><p>The type of join, such as INNER JOIN, LEFT JOIN.</p>
</td>
                </tr>
                            <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$table</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.string">string</a>|<a href="http://www.php.net/language.types.array">array</a></td>
                  <td class="param-desc-col"><p>The table to be joined.</p>
<p>Use a string to represent the name of the table to be joined.
The table name can contain a schema prefix (e.g. 'public.user') and/or table alias (e.g. 'user u').
The method will automatically quote the table name unless it contains some parenthesis
(which means the table is given as a sub-query or DB expression).</p>
<p>Use an array to represent joining with a sub-query. The array must contain only one element.
The value must be a <a href="yii-db-query.html">yii\db\Query</a> object representing the sub-query while the corresponding key
represents the alias for the sub-query.</p>
</td>
                </tr>
                            <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$on</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.string">string</a>|<a href="http://www.php.net/language.types.array">array</a></td>
                  <td class="param-desc-col"><p>The join condition that should appear in the ON part.
Please refer to <a href="yii-db-query.html#where()-detail">where()</a> on how to specify this parameter.</p>
<p>Note that the array format of <a href="yii-db-query.html#where()-detail">where()</a> is designed to match columns to values instead of columns to columns, so
the following would <strong>not</strong> work as expected: <code>['post.author_id' =&gt; 'user.id']</code>, it would
match the <code>post.author_id</code> column value against the string <code>'user.id'</code>.
It is recommended to use the string syntax here which is more suited for a join:</p>
<pre><code class="hljs php language-php"><span class="hljs-string">'post.author_id = user.id'</span>
</code></pre>
</td>
                </tr>
                            <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$params</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.array">array</a></td>
                  <td class="param-desc-col"><p>The parameters (name =&gt; value) to be bound to the query.</p>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col"><a href="yii-db-query.html">$this</a></td>
                  <td class="param-desc-col"><p>The query object itself</p>
</td>
                </tr>
                                    </table>

<!--	-->

    <div class="detail-header h3" id="leftJoin()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-db-query.html#leftJoin()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2/edit/master/framework/db/Query.php#L699" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2/blob/master/framework/db/Query.php#L699" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        leftJoin()
        <span class="detail-header-tag small">
            public                                    method
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Appends a LEFT OUTER JOIN part to the query.</strong></p>

        
            </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="yii-db-query.html">$this</a></span> <strong><a href="yii-db-query.html#leftJoin()-detail">leftJoin</a></strong> ( <span style="color: #0000BB">$table</span>, <span style="color: #0000BB">$on&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">''</span>, <span style="color: #0000BB">$params&nbsp;</span><span style="color: #007700">=&nbsp;[]</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$table</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.string">string</a>|<a href="http://www.php.net/language.types.array">array</a></td>
                  <td class="param-desc-col"><p>The table to be joined.</p>
<p>Use a string to represent the name of the table to be joined.
The table name can contain a schema prefix (e.g. 'public.user') and/or table alias (e.g. 'user u').
The method will automatically quote the table name unless it contains some parenthesis
(which means the table is given as a sub-query or DB expression).</p>
<p>Use an array to represent joining with a sub-query. The array must contain only one element.
The value must be a <a href="yii-db-query.html">yii\db\Query</a> object representing the sub-query while the corresponding key
represents the alias for the sub-query.</p>
</td>
                </tr>
                            <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$on</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.string">string</a>|<a href="http://www.php.net/language.types.array">array</a></td>
                  <td class="param-desc-col"><p>The join condition that should appear in the ON part.
Please refer to <a href="yii-db-query.html#join()-detail">join()</a> on how to specify this parameter.</p>
</td>
                </tr>
                            <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$params</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.array">array</a></td>
                  <td class="param-desc-col"><p>The parameters (name =&gt; value) to be bound to the query</p>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col"><a href="yii-db-query.html">$this</a></td>
                  <td class="param-desc-col"><p>The query object itself</p>
</td>
                </tr>
                                    </table>

<!--	-->

    <div class="detail-header h3" id="max()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-db-query.html#max()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2/edit/master/framework/db/Query.php#L350" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2/blob/master/framework/db/Query.php#L350" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        max()
        <span class="detail-header-tag small">
            public                                    method
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Returns the maximum of the specified column values.</strong></p>

        
            </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type">mixed</span> <strong><a href="yii-db-query.html#max()-detail">max</a></strong> ( <span style="color: #0000BB">$q</span>, <span style="color: #0000BB">$db&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">null</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$q</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.string">string</a></td>
                  <td class="param-desc-col"><p>The column name or expression.
Make sure you properly <a href="./guide-db-dao.html#quoting-table-and-column-names">quote</a> column names in the expression.</p>
</td>
                </tr>
                            <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$db</span></td>
                  <td class="param-type-col"><a href="yii-db-connection.html">yii\db\Connection</a></td>
                  <td class="param-desc-col"><p>The database connection used to generate the SQL statement.
If this parameter is not given, the <code>db</code> application component will be used.</p>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col">mixed</td>
                  <td class="param-desc-col"><p>The maximum of the specified column values.</p>
</td>
                </tr>
                                    </table>

<!--	-->

    <div class="detail-header h3" id="min()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-db-query.html#min()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2/edit/master/framework/db/Query.php#L337" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2/blob/master/framework/db/Query.php#L337" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        min()
        <span class="detail-header-tag small">
            public                                    method
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Returns the minimum of the specified column values.</strong></p>

        
            </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type">mixed</span> <strong><a href="yii-db-query.html#min()-detail">min</a></strong> ( <span style="color: #0000BB">$q</span>, <span style="color: #0000BB">$db&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">null</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$q</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.string">string</a></td>
                  <td class="param-desc-col"><p>The column name or expression.
Make sure you properly <a href="./guide-db-dao.html#quoting-table-and-column-names">quote</a> column names in the expression.</p>
</td>
                </tr>
                            <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$db</span></td>
                  <td class="param-type-col"><a href="yii-db-connection.html">yii\db\Connection</a></td>
                  <td class="param-desc-col"><p>The database connection used to generate the SQL statement.
If this parameter is not given, the <code>db</code> application component will be used.</p>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col">mixed</td>
                  <td class="param-desc-col"><p>The minimum of the specified column values.</p>
</td>
                </tr>
                                    </table>

<!--	-->

    <div class="detail-header h3" id="one()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-db-query.html#one()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2/edit/master/framework/db/Query.php#L245" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2/blob/master/framework/db/Query.php#L245" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        one()
        <span class="detail-header-tag small">
            public                                    method
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Executes the query and returns a single row of result.</strong></p>

        
            </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="http://www.php.net/language.types.array">array</a>|<a href="http://www.php.net/language.types.boolean">boolean</a></span> <strong><a href="yii-db-query.html#one()-detail">one</a></strong> ( <span style="color: #0000BB">$db&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">null</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$db</span></td>
                  <td class="param-type-col"><a href="yii-db-connection.html">yii\db\Connection</a></td>
                  <td class="param-desc-col"><p>The database connection used to generate the SQL statement.
If this parameter is not given, the <code>db</code> application component will be used.</p>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.array">array</a>|<a href="http://www.php.net/language.types.boolean">boolean</a></td>
                  <td class="param-desc-col"><p>The first row (in terms of an array) of the query result. False is returned if the query
results in nothing.</p>
</td>
                </tr>
                                    </table>

<!--	-->

    <div class="detail-header h3" id="orHaving()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-db-query.html#orHaving()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2/edit/master/framework/db/Query.php#L832" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2/blob/master/framework/db/Query.php#L832" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        orHaving()
        <span class="detail-header-tag small">
            public                                    method
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Adds an additional HAVING condition to the existing one.</strong></p>

        <p>The new condition and the existing one will be joined using the 'OR' operator.</p>

        <p>See also:</p><ul><li><a href="yii-db-query.html#having()-detail">having()</a></li><li><a href="yii-db-query.html#andHaving()-detail">andHaving()</a></li></ul>    </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="yii-db-query.html">$this</a></span> <strong><a href="yii-db-query.html#orHaving()-detail">orHaving</a></strong> ( <span style="color: #0000BB">$condition</span>, <span style="color: #0000BB">$params&nbsp;</span><span style="color: #007700">=&nbsp;[]</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$condition</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.string">string</a>|<a href="http://www.php.net/language.types.array">array</a>|<a href="yii-db-expression.html">yii\db\Expression</a></td>
                  <td class="param-desc-col"><p>The new HAVING condition. Please refer to <a href="yii-db-query.html#where()-detail">where()</a>
on how to specify this parameter.</p>
</td>
                </tr>
                            <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$params</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.array">array</a></td>
                  <td class="param-desc-col"><p>The parameters (name =&gt; value) to be bound to the query.</p>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col"><a href="yii-db-query.html">$this</a></td>
                  <td class="param-desc-col"><p>The query object itself</p>
</td>
                </tr>
                                    </table>

<!--	-->

    <div class="detail-header h3" id="orWhere()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-db-query.html#orWhere()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2/edit/master/framework/db/Query.php#L573" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2/blob/master/framework/db/Query.php#L573" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        orWhere()
        <span class="detail-header-tag small">
            public                                    method
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Adds an additional WHERE condition to the existing one.</strong></p>

        <p>The new condition and the existing one will be joined using the 'OR' operator.</p>

        <p>See also:</p><ul><li><a href="yii-db-query.html#where()-detail">where()</a></li><li><a href="yii-db-query.html#andWhere()-detail">andWhere()</a></li></ul>    </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="yii-db-query.html">$this</a></span> <strong><a href="yii-db-query.html#orWhere()-detail">orWhere</a></strong> ( <span style="color: #0000BB">$condition</span>, <span style="color: #0000BB">$params&nbsp;</span><span style="color: #007700">=&nbsp;[]</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$condition</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.string">string</a>|<a href="http://www.php.net/language.types.array">array</a>|<a href="yii-db-expression.html">yii\db\Expression</a></td>
                  <td class="param-desc-col"><p>The new WHERE condition. Please refer to <a href="yii-db-query.html#where()-detail">where()</a>
on how to specify this parameter.</p>
</td>
                </tr>
                            <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$params</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.array">array</a></td>
                  <td class="param-desc-col"><p>The parameters (name =&gt; value) to be bound to the query.</p>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col"><a href="yii-db-query.html">$this</a></td>
                  <td class="param-desc-col"><p>The query object itself</p>
</td>
                </tr>
                                    </table>

<!--	-->

    <div class="detail-header h3" id="params()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-db-query.html#params()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2/edit/master/framework/db/Query.php#L862" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2/blob/master/framework/db/Query.php#L862" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        params()
        <span class="detail-header-tag small">
            public                                    method
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Sets the parameters to be bound to the query.</strong></p>

        
        <p>See also <a href="yii-db-query.html#addParams()-detail">addParams()</a>.</p>    </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="yii-db-query.html">$this</a></span> <strong><a href="yii-db-query.html#params()-detail">params</a></strong> ( <span style="color: #0000BB">$params</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$params</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.array">array</a></td>
                  <td class="param-desc-col"><p>List of query parameter values indexed by parameter placeholders.
For example, <code>[':name' =&gt; 'Dan', ':age' =&gt; 31]</code>.</p>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col"><a href="yii-db-query.html">$this</a></td>
                  <td class="param-desc-col"><p>The query object itself</p>
</td>
                </tr>
                                    </table>

<!--	-->

    <div class="detail-header h3" id="populate()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-db-query.html#populate()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2/edit/master/framework/db/Query.php#L221" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2/blob/master/framework/db/Query.php#L221" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        populate()
        <span class="detail-header-tag small">
            public                                    method
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Converts the raw query results into the format as specified by this query.</strong></p>

        <p>This method is internally used to convert the data fetched from database
into the format as required by this query.</p>

            </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="http://www.php.net/language.types.array">array</a></span> <strong><a href="yii-db-query.html#populate()-detail">populate</a></strong> ( <span style="color: #0000BB">$rows</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$rows</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.array">array</a></td>
                  <td class="param-desc-col"><p>The raw query result from database</p>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.array">array</a></td>
                  <td class="param-desc-col"><p>The converted query result</p>
</td>
                </tr>
                                    </table>

<!--	-->

    <div class="detail-header h3" id="prepare()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-db-query.html#prepare()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2/edit/master/framework/db/Query.php#L138" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2/blob/master/framework/db/Query.php#L138" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        prepare()
        <span class="detail-header-tag small">
            public                                    method
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Prepares for building SQL.</strong></p>

        <p>This method is called by <a href="yii-db-querybuilder.html">yii\db\QueryBuilder</a> when it starts to build SQL from a query object.
You may override this method to do some final preparation work when converting a query into a SQL statement.</p>

            </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="yii-db-query.html">$this</a></span> <strong><a href="yii-db-query.html#prepare()-detail">prepare</a></strong> ( <span style="color: #0000BB">$builder</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$builder</span></td>
                  <td class="param-type-col"><a href="yii-db-querybuilder.html">yii\db\QueryBuilder</a></td>
                  <td class="param-desc-col"></td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col"><a href="yii-db-query.html">$this</a></td>
                  <td class="param-desc-col"><p>A prepared query instance which will be used by <a href="yii-db-querybuilder.html">yii\db\QueryBuilder</a> to build the SQL</p>
</td>
                </tr>
                                    </table>

<!--	-->

    <div class="detail-header h3" id="queryScalar()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-db-query.html#queryScalar()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2/edit/master/framework/db/Query.php#L377" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2/blob/master/framework/db/Query.php#L377" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        queryScalar()
        <span class="detail-header-tag small">
            protected                                    method
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Queries a scalar value by setting <a href="yii-db-query.html#select()-detail">select()</a> first.</strong></p>

        <p>Restores the value of select to make this query reusable.</p>

            </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">protected</span> <span class="signature-type"><a href="http://www.php.net/language.types.boolean">boolean</a>|<a href="http://www.php.net/language.types.string">string</a></span> <strong><a href="yii-db-query.html#queryScalar()-detail">queryScalar</a></strong> ( <span style="color: #0000BB">$selectExpression</span>, <span style="color: #0000BB">$db</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$selectExpression</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.string">string</a>|<a href="yii-db-expression.html">yii\db\Expression</a></td>
                  <td class="param-desc-col"></td>
                </tr>
                            <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$db</span></td>
                  <td class="param-type-col"><a href="yii-db-connection.html">yii\db\Connection</a>|<a href="http://www.php.net/language.types.null">null</a></td>
                  <td class="param-desc-col"></td>
                </tr>
                                                </table>

<!--	-->

    <div class="detail-header h3" id="rightJoin()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-db-query.html#rightJoin()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2/edit/master/framework/db/Query.php#L723" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2/blob/master/framework/db/Query.php#L723" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        rightJoin()
        <span class="detail-header-tag small">
            public                                    method
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Appends a RIGHT OUTER JOIN part to the query.</strong></p>

        
            </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="yii-db-query.html">$this</a></span> <strong><a href="yii-db-query.html#rightJoin()-detail">rightJoin</a></strong> ( <span style="color: #0000BB">$table</span>, <span style="color: #0000BB">$on&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">''</span>, <span style="color: #0000BB">$params&nbsp;</span><span style="color: #007700">=&nbsp;[]</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$table</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.string">string</a>|<a href="http://www.php.net/language.types.array">array</a></td>
                  <td class="param-desc-col"><p>The table to be joined.</p>
<p>Use a string to represent the name of the table to be joined.
The table name can contain a schema prefix (e.g. 'public.user') and/or table alias (e.g. 'user u').
The method will automatically quote the table name unless it contains some parenthesis
(which means the table is given as a sub-query or DB expression).</p>
<p>Use an array to represent joining with a sub-query. The array must contain only one element.
The value must be a <a href="yii-db-query.html">yii\db\Query</a> object representing the sub-query while the corresponding key
represents the alias for the sub-query.</p>
</td>
                </tr>
                            <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$on</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.string">string</a>|<a href="http://www.php.net/language.types.array">array</a></td>
                  <td class="param-desc-col"><p>The join condition that should appear in the ON part.
Please refer to <a href="yii-db-query.html#join()-detail">join()</a> on how to specify this parameter.</p>
</td>
                </tr>
                            <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$params</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.array">array</a></td>
                  <td class="param-desc-col"><p>The parameters (name =&gt; value) to be bound to the query</p>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col"><a href="yii-db-query.html">$this</a></td>
                  <td class="param-desc-col"><p>The query object itself</p>
</td>
                </tr>
                                    </table>

<!--	-->

    <div class="detail-header h3" id="scalar()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-db-query.html#scalar()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2/edit/master/framework/db/Query.php#L258" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2/blob/master/framework/db/Query.php#L258" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        scalar()
        <span class="detail-header-tag small">
            public                                    method
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Returns the query result as a scalar value.</strong></p>

        <p>The value returned will be the first column in the first row of the query results.</p>

            </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="http://www.php.net/language.types.string">string</a>|<a href="http://www.php.net/language.types.null">null</a>|<a href="http://www.php.net/language.types.boolean">false</a></span> <strong><a href="yii-db-query.html#scalar()-detail">scalar</a></strong> ( <span style="color: #0000BB">$db&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">null</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$db</span></td>
                  <td class="param-type-col"><a href="yii-db-connection.html">yii\db\Connection</a></td>
                  <td class="param-desc-col"><p>The database connection used to generate the SQL statement.
If this parameter is not given, the <code>db</code> application component will be used.</p>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.string">string</a>|<a href="http://www.php.net/language.types.null">null</a>|<a href="http://www.php.net/language.types.boolean">false</a></td>
                  <td class="param-desc-col"><p>The value of the first column in the first row of the query result.
False is returned if the query result is empty.</p>
</td>
                </tr>
                                    </table>

<!--	-->

    <div class="detail-header h3" id="select()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-db-query.html#select()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2/edit/master/framework/db/Query.php#L424" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2/blob/master/framework/db/Query.php#L424" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        select()
        <span class="detail-header-tag small">
            public                                    method
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Sets the SELECT part of the query.</strong></p>

        
            </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="yii-db-query.html">$this</a></span> <strong><a href="yii-db-query.html#select()-detail">select</a></strong> ( <span style="color: #0000BB">$columns</span>, <span style="color: #0000BB">$option&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">null</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$columns</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.string">string</a>|<a href="http://www.php.net/language.types.array">array</a>|<a href="yii-db-expression.html">yii\db\Expression</a></td>
                  <td class="param-desc-col"><p>The columns to be selected.
Columns can be specified in either a string (e.g. "id, name") or an array (e.g. ['id', 'name']).
Columns can be prefixed with table names (e.g. "user.id") and/or contain column aliases (e.g. "user.id AS user_id").
The method will automatically quote the column names unless a column contains some parenthesis
(which means the column contains a DB expression). A DB expression may also be passed in form of
an <a href="yii-db-expression.html">yii\db\Expression</a> object.</p>
<p>Note that if you are selecting an expression like <code>CONCAT(first_name, ' ', last_name)</code>, you should
use an array to specify the columns. Otherwise, the expression may be incorrectly split into several parts.</p>
<p>When the columns are specified as an array, you may also use array keys as the column aliases (if a column
does not need alias, do not use a string key).</p>
<p>Starting from version 2.0.1, you may also select sub-queries as columns by specifying each such column
as a <code>Query</code> instance representing the sub-query.</p>
</td>
                </tr>
                            <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$option</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.string">string</a></td>
                  <td class="param-desc-col"><p>Additional option that should be appended to the 'SELECT' keyword. For example,
in MySQL, the option 'SQL_CALC_FOUND_ROWS' can be used.</p>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col"><a href="yii-db-query.html">$this</a></td>
                  <td class="param-desc-col"><p>The query object itself</p>
</td>
                </tr>
                                    </table>

<!--	-->

    <div class="detail-header h3" id="sum()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-db-query.html#sum()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2/edit/master/framework/db/Query.php#L311" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2/blob/master/framework/db/Query.php#L311" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        sum()
        <span class="detail-header-tag small">
            public                                    method
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Returns the sum of the specified column values.</strong></p>

        
            </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type">mixed</span> <strong><a href="yii-db-query.html#sum()-detail">sum</a></strong> ( <span style="color: #0000BB">$q</span>, <span style="color: #0000BB">$db&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">null</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$q</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.string">string</a></td>
                  <td class="param-desc-col"><p>The column name or expression.
Make sure you properly <a href="./guide-db-dao.html#quoting-table-and-column-names">quote</a> column names in the expression.</p>
</td>
                </tr>
                            <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$db</span></td>
                  <td class="param-type-col"><a href="yii-db-connection.html">yii\db\Connection</a></td>
                  <td class="param-desc-col"><p>The database connection used to generate the SQL statement.
If this parameter is not given, the <code>db</code> application component will be used.</p>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col">mixed</td>
                  <td class="param-desc-col"><p>The sum of the specified column values.</p>
</td>
                </tr>
                                    </table>

<!--	-->

    <div class="detail-header h3" id="union()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-db-query.html#union()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2/edit/master/framework/db/Query.php#L849" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2/blob/master/framework/db/Query.php#L849" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        union()
        <span class="detail-header-tag small">
            public                                    method
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Appends a SQL statement using UNION operator.</strong></p>

        
            </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="yii-db-query.html">$this</a></span> <strong><a href="yii-db-query.html#union()-detail">union</a></strong> ( <span style="color: #0000BB">$sql</span>, <span style="color: #0000BB">$all&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">false</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$sql</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.string">string</a>|<a href="yii-db-query.html">yii\db\Query</a></td>
                  <td class="param-desc-col"><p>The SQL statement to be appended using UNION</p>
</td>
                </tr>
                            <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$all</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.boolean">boolean</a></td>
                  <td class="param-desc-col"><p>TRUE if using UNION ALL and FALSE if using UNION</p>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col"><a href="yii-db-query.html">$this</a></td>
                  <td class="param-desc-col"><p>The query object itself</p>
</td>
                </tr>
                                    </table>

<!--	-->

    <div class="detail-header h3" id="where()-detail">
        <a href="#" class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
        <a class="tool-link hash" href="yii-db-query.html#where()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
                    <a href="https://github.com/yiisoft/yii2/edit/master/framework/db/Query.php#L535" class="tool-link" title="edit on github"><span class="glyphicon glyphicon-pencil"></span></a>
            <a href="https://github.com/yiisoft/yii2/blob/master/framework/db/Query.php#L535" class="tool-link" title="view source on github"><span class="glyphicon glyphicon-eye-open"></span></a>
        
        where()
        <span class="detail-header-tag small">
            public                                    method
                    </span>
    </div>

    <div class="doc-description">
        <p><strong>Sets the WHERE part of the query.</strong></p>

        <p>The method requires a <code>$condition</code> parameter, and optionally a <code>$params</code> parameter
specifying the values to be bound to the query.</p>
<p>The <code>$condition</code> parameter should be either a string (e.g. <code>'id=1'</code>) or an array.</p>
<p>The <code>$condition</code> specified as an array can be in one of the following two formats:</p>
<ul>
<li>hash format: <code>['column1' =&gt; value1, 'column2' =&gt; value2, ...]</code></li>
<li>operator format: <code>[operator, operand1, operand2, ...]</code></li>
</ul>
<p>A condition in hash format represents the following SQL expression in general:
<code>column1=value1 AND column2=value2 AND ...</code>. In case when a value is an array,
an <code>IN</code> expression will be generated. And if a value is <code>null</code>, <code>IS NULL</code> will be used
in the generated expression. Below are some examples:</p>
<ul>
<li><code>['type' =&gt; 1, 'status' =&gt; 2]</code> generates <code>(type = 1) AND (status = 2)</code>.</li>
<li><code>['id' =&gt; [1, 2, 3], 'status' =&gt; 2]</code> generates <code>(id IN (1, 2, 3)) AND (status = 2)</code>.</li>
<li><code>['status' =&gt; null]</code> generates <code>status IS NULL</code>.</li>
</ul>
<p>A condition in operator format generates the SQL expression according to the specified operator, which
can be one of the following:</p>
<ul>
<li><p><strong>and</strong>: the operands should be concatenated together using <code>AND</code>. For example,
<code>['and', 'id=1', 'id=2']</code> will generate <code>id=1 AND id=2</code>. If an operand is an array,
it will be converted into a string using the rules described here. For example,
<code>['and', 'type=1', ['or', 'id=1', 'id=2']]</code> will generate <code>type=1 AND (id=1 OR id=2)</code>.
The method will <em>not</em> do any quoting or escaping.</p>
</li>
<li><p><strong>or</strong>: similar to the <code>and</code> operator except that the operands are concatenated using <code>OR</code>. For example,
<code>['or', ['type' =&gt; [7, 8, 9]], ['id' =&gt; [1, 2, 3]]]</code> will generate <code>(type IN (7, 8, 9) OR (id IN (1, 2, 3)))</code>.</p>
</li>
<li><p><strong>not</strong>: this will take only one operand and build the negation of it by prefixing the query string with <code>NOT</code>.
For example <code>['not', ['attribute' =&gt; null]]</code> will result in the condition <code>NOT (attribute IS NULL)</code>.</p>
</li>
<li><p><strong>between</strong>: operand 1 should be the column name, and operand 2 and 3 should be the
starting and ending values of the range that the column is in.
For example, <code>['between', 'id', 1, 10]</code> will generate <code>id BETWEEN 1 AND 10</code>.</p>
</li>
<li><p><strong>not between</strong>: similar to <code>between</code> except the <code>BETWEEN</code> is replaced with <code>NOT BETWEEN</code>
in the generated condition.</p>
</li>
<li><p><strong>in</strong>: operand 1 should be a column or DB expression, and operand 2 be an array representing
the range of the values that the column or DB expression should be in. For example,
<code>['in', 'id', [1, 2, 3]]</code> will generate <code>id IN (1, 2, 3)</code>.
The method will properly quote the column name and escape values in the range.</p>
<p>To create a composite <code>IN</code> condition you can use and array for the column name and value, where the values are indexed by the column name:
<code>['in', ['id', 'name'], [['id' =&gt; 1, 'name' =&gt; 'foo'], ['id' =&gt; 2, 'name' =&gt; 'bar']] ]</code>.</p>
<p>You may also specify a sub-query that is used to get the values for the <code>IN</code>-condition:
<code>['in', 'user_id', (new Query())-&gt;select('id')-&gt;from('users')-&gt;where(['active' =&gt; 1])]</code></p>
</li>
<li><p><strong>not in</strong>: similar to the <code>in</code> operator except that <code>IN</code> is replaced with <code>NOT IN</code> in the generated condition.</p>
</li>
<li><p><strong>like</strong>: operand 1 should be a column or DB expression, and operand 2 be a string or an array representing
the values that the column or DB expression should be like.
For example, <code>['like', 'name', 'tester']</code> will generate <code>name LIKE '%tester%'</code>.
When the value range is given as an array, multiple <code>LIKE</code> predicates will be generated and concatenated
using <code>AND</code>. For example, <code>['like', 'name', ['test', 'sample']]</code> will generate
<code>name LIKE '%test%' AND name LIKE '%sample%'</code>.
The method will properly quote the column name and escape special characters in the values.
Sometimes, you may want to add the percentage characters to the matching value by yourself, you may supply
a third operand <code>false</code> to do so. For example, <code>['like', 'name', '%tester', false]</code> will generate <code>name LIKE '%tester'</code>.</p>
</li>
<li><p><strong>or like</strong>: similar to the <code>like</code> operator except that <code>OR</code> is used to concatenate the <code>LIKE</code>
predicates when operand 2 is an array.</p>
</li>
<li><p><strong>not like</strong>: similar to the <code>like</code> operator except that <code>LIKE</code> is replaced with <code>NOT LIKE</code>
in the generated condition.</p>
</li>
<li><p><strong>or not like</strong>: similar to the <code>not like</code> operator except that <code>OR</code> is used to concatenate
the <code>NOT LIKE</code> predicates.</p>
</li>
<li><p><strong>exists</strong>: operand 1 is a query object that used to build an <code>EXISTS</code> condition. For example
<code>['exists', (new Query())-&gt;select('id')-&gt;from('users')-&gt;where(['active' =&gt; 1])]</code> will result in the following SQL expression:
<code>EXISTS (SELECT "id" FROM "users" WHERE "active"=1)</code>.</p>
</li>
<li><p><strong>not exists</strong>: similar to the <code>exists</code> operator except that <code>EXISTS</code> is replaced with <code>NOT EXISTS</code> in the generated condition.</p>
</li>
<li><p>Additionally you can specify arbitrary operators as follows: A condition of <code>['&gt;=', 'id', 10]</code> will result in the
following SQL expression: <code>id &gt;= 10</code>.</p>
</li>
</ul>

        <p>See also:</p><ul><li><a href="yii-db-query.html#andWhere()-detail">andWhere()</a></li><li><a href="yii-db-query.html#orWhere()-detail">orWhere()</a></li><li><a href="yii-db-queryinterface.html#where()-detail">yii\db\QueryInterface::where()</a></li></ul>    </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="yii-db-query.html">$this</a></span> <strong><a href="yii-db-query.html#where()-detail">where</a></strong> ( <span style="color: #0000BB">$condition</span>, <span style="color: #0000BB">$params&nbsp;</span><span style="color: #007700">=&nbsp;[]</span> )</td></tr>
                                    <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$condition</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.string">string</a>|<a href="http://www.php.net/language.types.array">array</a>|<a href="yii-db-expression.html">yii\db\Expression</a></td>
                  <td class="param-desc-col"><p>The conditions that should be put in the WHERE part.</p>
</td>
                </tr>
                            <tr>
                  <td class="param-name-col"><span style="color: #0000BB">$params</span></td>
                  <td class="param-type-col"><a href="http://www.php.net/language.types.array">array</a></td>
                  <td class="param-desc-col"><p>The parameters (name =&gt; value) to be bound to the query.</p>
</td>
                </tr>
                                        <tr>
                  <th class="param-name-col">return</th>
                  <td class="param-type-col"><a href="yii-db-query.html">$this</a></td>
                  <td class="param-desc-col"><p>The query object itself</p>
</td>
                </tr>
                                    </table>

<!--	-->
</div>
        </div>
</div>

<script type="text/javascript">
    /*<![CDATA[*/
    $("a.toggle").on('click', function () {
        var $this = $(this);
        if ($this.hasClass('properties-hidden')) {
            $this.text($this.text().replace(/Show/,'Hide'));
            $this.parents(".summary").find(".inherited").show();
            $this.removeClass('properties-hidden');
        } else {
            $this.text($this.text().replace(/Hide/,'Show'));
            $this.parents(".summary").find(".inherited").hide();
            $this.addClass('properties-hidden');
        }

        return false;
    });
    /*
     $(".sourceCode a.show").toggle(function () {
     $(this).text($(this).text().replace(/show/,'hide'));
     $(this).parents(".sourceCode").find("div.code").show();
     },function () {
     $(this).text($(this).text().replace(/hide/,'show'));
     $(this).parents(".sourceCode").find("div.code").hide();
     });
     $("a.sourceLink").click(function () {
     $(this).attr('target','_blank');
     });
     */
    /*]]>*/
</script>


</div>

<footer class="footer">
        <p class="pull-right"><small>Page generated on Sat, 09 Jul 2016 12:15:49 +0000</small></p>
    Powered by <a href="http://www.yiiframework.com/" rel="external">Yii Framework</a></footer>

<script type="text/javascript">jQuery(document).ready(function () {
    var shiftWindow = function () { scrollBy(0, -50) };
    if (location.hash) setTimeout(shiftWindow, 1);
    window.addEventListener("hashchange", shiftWindow);
var element = document.createElement("script");
element.src = "./jssearch.index.js";
document.body.appendChild(element);

var searchBox = $('#searchbox');

// search when typing in search field
searchBox.on("keyup", function(event) {
    var query = $(this).val();

    if (query == '' || event.which == 27) {
        $('#search-resultbox').hide();
        return;
    } else if (event.which == 13) {
        var selectedLink = $('#search-resultbox a.selected');
        if (selectedLink.length != 0) {
            document.location = selectedLink.attr('href');
            return;
        }
    } else if (event.which == 38 || event.which == 40) {
        $('#search-resultbox').show();

        var selected = $('#search-resultbox a.selected');
        if (selected.length == 0) {
            $('#search-results').find('a').first().addClass('selected');
        } else {
            var next;
            if (event.which == 40) {
                next = selected.parent().next().find('a').first();
            } else {
                next = selected.parent().prev().find('a').first();
            }
            if (next.length != 0) {
                var resultbox = $('#search-results');
                var position = next.position();

//              TODO scrolling is buggy and jumps around
//                resultbox.scrollTop(Math.floor(position.top));
//                console.log(position.top);

                selected.removeClass('selected');
                next.addClass('selected');
            }
        }

        return;
    }
    $('#search-resultbox').show();
    $('#search-results').html('<li><span class="no-results">No results</span></li>');

    var result = jssearch.search(query);

    if (result.length > 0) {
        var i = 0;
        var resHtml = '';

        for (var key in result) {
            if (i++ > 20) {
                break;
            }
            resHtml = resHtml +
            '<li><a href="' + result[key].file.u.substr(3) +'"><span class="title">' + result[key].file.t + '</span>' +
            '<span class="description">' + result[key].file.d + '</span></a></li>';
        }
        $('#search-results').html(resHtml);
    }
});

// hide the search results on ESC
$(document).on("keyup", function(event) { if (event.which == 27) { $('#search-resultbox').hide(); } });
// hide search results on click to document
$(document).bind('click', function (e) { $('#search-resultbox').hide(); });
// except the following:
searchBox.bind('click', function(e) { e.stopPropagation(); });
$('#search-resultbox').bind('click', function(e) { e.stopPropagation(); });

});</script></body>
</html>
